0

while building up a user Interface I made use of ActiveX buttons in VBA2010. I wrote the Macros first, checked them, then copied them into the ActiceX button code.

The macro then crashes at a range command of another sheet. To test it I separated the commands:

Sheets("Data").Visible = xlSheetVisible 
Sheets("Data").Select                   
Columns("O:O").Select         ' The code crashes here

As a result I get a 1004 runtime error. I found a similar topic which seems to be unsolved aswell.

Unable to Execute Macro With ActiveX Controls (Excel VBA)

Help is well appreciated. Thanks in advance!

Community
  • 1
  • 1
yfro
  • 47
  • 9

1 Answers1

0

Select is not recommended.Modify your code to

 Dim ws As Worksheet
 Set ws = Sheets("Data")
 ws.Visible = xlSheetVisible
 ws.Select
 With ws
 .Columns("O:O").Select
 End With
Neelesh
  • 138
  • 1
  • 10