开发者

Issue with Z-Order

开发者 https://www.devze.com 2022-12-27 06:40 出处:网络
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 ch

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号