![]() |
![]() |
|
|||||||
| Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
New Member
Join Date: May 2002
Posts: 48
|
I created a macro that runs pretty good which, filters my master database, copies and pastes on another sheet. When i attempt to place the code in commandbutton, error reads select method of range class failed, any ideas?
[ This Message was edited by: Nathalie on 2002-05-24 12:40 ] [ This Message was edited by: Nathalie on 2002-05-24 12:45 ] |
|
|
|
|
|
#2 |
|
MrExcel MVP
Join Date: Feb 2002
Location: Central Florida, USA
Posts: 7,541
|
Most code will work if you use a Form-Button, but will need to be re-written if you use any other button!
View-Toolbars-select "Forms"-then the button icon. Attach the macro code to the button. Delete the button caption, right click the button, select format, select font-bold, select color, OK. Then type your button caption, re-size the button to your needs. Hope this helps. JSW |
|
|
|
|
|
#3 |
|
Board Regular
Join Date: May 2002
Posts: 206
|
The select method for the range is failing because an object has not been properly declared.
Rather than moving the code you could try this for now: Private Sub CommandButton1_Click() Call Macro1 End Sub To do this the macro must be a Sub, not Private Sub. |
|
|
|
|
|
#4 |
|
New Member
Join Date: May 2002
Posts: 48
|
I tried the method of calling my macro and tells me that sub or function is not defined???
Call macroname? What could be wrong [ This Message was edited by: Nathalie on 2002-05-24 12:43 ] |
|
|
|
|
|
#5 |
|
Board Regular
Join Date: May 2002
Posts: 206
|
It sounds like the Call failed because you are wanting to select a range on another sheet.
If you have the command button on sheet1 and you want to select a range on sheet1 you have this Range("A1").Select If you have the command button on sheet2 and you want to select a range on sheet1 you have this Sheets("Sheet1").Select Range("A1").Select |
|
|
|
|
|
#6 |
|
New Member
Join Date: May 2002
Posts: 48
|
I think i got it. Thanks for all the help!
Nathalie |
|
|
|
|
|
#7 | |
|
MrExcel MVP
Join Date: Feb 2002
Location: Auckland, New Zealand
Posts: 4,209
|
Quote:
Excel97 ?? If so the there is a problem in calling routines that Act on other Objects called from ActiveX commandbuttons. The workaround for this is to; 1) Just select a cell before the call in your macro OR Bst option 2) Set the commandbuttons [TakeFocus*******] to False. |
|
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|