Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Excel code runs on toolbar button, but not on command button

Status
Not open for further replies.

sazi22

Technical User
Oct 7, 2004
43
0
0
US
I copy and pasted code to a command button, but I get the error "Select method of range class failed." The line of code that has the issue is this:

Columns("N:N").Select

It gives me no trouble when I run the code from a toolbar button.

I also do not have the option to "assign macro" to the command button when I right click.

Thanks
 
1. did you insert the commandbutton from the Controls toolbar?

2. what module as you running the command from?

Gerry
 
1. Yes

2. It's not running from a module. It's attached to the worksheet.
 
If you right click the commandbutton, and select View code, and paste in:

Columns("N:N").Select

in the procedure CommandButton1_Click, then clicking the commandbutton does in fact do the selection.

Where did you paste the code?

Gerry
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top