I have created a command button that plays the following macro.
The command button is on Sheet1 and when I click the command button and the macro plays it will select Sheet2 and the range B10:C19, and returns a Run Time Error '1004': Select method of Range class failed.Code:Private Sub CommandButton1_Click() Sheets("Sheet2").Select Range("B10:C19").Select End Sub
I have tried to play the macro without using the command button and it will select the range from Sheet2 without any problems/errors. I change the macro to select the range on Sheet1 and it works fine. I know the issue has something to do with the command button and can not figure it out.
I am not sure what I am missing. Any help would be greatly appreciated.
Last edited by randolphoralph; 11-20-2009 at 05:02 PM.
Just add the sheet reference to the range...
The code is executing from Sheet1, so when Sheet2 is selected it is trying to select the range on Sheet1 (the Macro is not tied to the sheet, so that's why it works).Code:Private Sub CommandButton1_Click() Sheets("Sheet2").Select Sheets("Sheet2").Range("B10:C19").Select End Sub
It worked! Thank you so much
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks