Issue with Z-Order
I have multiple shapes and checkboxes in a spreadsheet. I want to create a function that places a particular shape to front (a higher Z开发者_如何学JAVA-order than its peers) when its corresponding checkbox is clicked. This is the code that I currently have:
Sub CheckBox3_Click()
If CheckBox3.Value = True Then
Sheet1.Shapes("blueoval").ZOrder msoBringToFront
End If
End Sub
I get Run-time Error '424' whenever I run this code. I am new to VBA for excel, so any help would be greatly appreciated. What's wrong with this code? What's missing? etc.. Thanks!
Your code works for me.
Check that:
Your checkbox is an ActiveX control and not a Form control. The checkbox name is CheckBox3. You have a shape on Sheet1 called blueoval. The sheet name with the blue oval is actually Sheet1 (check this in the Visual Basic Editor). In the Visual Basic Editor, select Tools > References and make sure there are no references marked MISSING. Your code is on the worksheet where the checkbox is and not in a separate module.
精彩评论