PDA

View Full Version : Command Button



nicolaforni
05-19-2011, 03:42 AM
Hi,

I created a code whereby I start in sheet1 then I go into a sheet2 then I do a shift-F9 and then I go back to original sheet. Very simple and it works. I then copy this code and paste it in a Command Button and I get the error message "Select method of range class failed".

Can someone explain why?

:dunno

Code below:
Sheets("Sheets2").Select
Application.Run "BLPLinkReset"
Range("B14").Select
ActiveSheet.Calculate
Sheets("Sheets1").Select
Application.Run "BLPLinkReset"
Range("C19").Select
End Sub

Thanks!
Nic

Odyrus
05-19-2011, 06:09 AM
You should put your code into a macro (hit alt+F11, add a module and paste yer code) then assign that macro to the command button.

Might want to name your code, too. Put Sub MyMacro() before your code.

nicolaforni
05-19-2011, 07:40 AM
Thanks!
Nic