Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.misc
|
|||
|
|||
Macro Button
I have written a macro to change the currency format of certain cells on a
number of different sheets in one workbook. It works when i run it through tools/macros/ run, but goes into error when i try and run it from a click button, any ideas |
#2
Posted to microsoft.public.excel.misc
|
|||
|
|||
Macro Button
Hello Gary
If you are running code from a commandbutton from the Controls tool box then consider setting the TakeFocusOnClick property to false. HTH Cordially Pascal "Gary" a écrit dans le message de news: ... I have written a macro to change the currency format of certain cells on a number of different sheets in one workbook. It works when i run it through tools/macros/ run, but goes into error when i try and run it from a click button, any ideas |
#3
Posted to microsoft.public.excel.misc
|
|||
|
|||
Macro Button
I still get "select method of range class failed" and highlights the following
Range("E:E,G:G,H:H,I:I,J:J,F24:F26").Select "papou" wrote: Hello Gary If you are running code from a commandbutton from the Controls tool box then consider setting the TakeFocusOnClick property to false. HTH Cordially Pascal "Gary" a écrit dans le message de news: ... I have written a macro to change the currency format of certain cells on a number of different sheets in one workbook. It works when i run it through tools/macros/ run, but goes into error when i try and run it from a click button, any ideas |
#5
Posted to microsoft.public.excel.misc
|
|||
|
|||
Macro Button
An unqualifed range will refer to the activesheet if the code is in a general
module. An unqualified range will refer to the worksheet that owns the code if it's in a worksheet module. So if you do: worksheets("sheet99").select range("E:E,G:G,H:H,I:I,J:J,F24:F26").select This will work in a general module. That range will be selected. But when the code is behind a worksheet, the activesheet is sheet99. But you're trying to select a range on the sheet that owns the code. Since you can only select a range on the active sheet, your code bombs. You could use: worksheets("sheet99").select worksheets("sheet99").range("E:E,G:G,H:H,I:I,J:J,F 24:F26").select or with worksheets("sheet99") .select .range("E:E,G:G,H:H,I:I,J:J,F24:F26").select End with But better is to drop the select's and just do the work on the range you want: worksheets("sheet99").range("E:E,G:G,H:H,I:I,J:J,F 24:F26").numberformat = "0" Gary wrote: I still get "select method of range class failed" and highlights the following Range("E:E,G:G,H:H,I:I,J:J,F24:F26").Select "papou" wrote: Hello Gary If you are running code from a commandbutton from the Controls tool box then consider setting the TakeFocusOnClick property to false. HTH Cordially Pascal "Gary" a écrit dans le message de news: ... I have written a macro to change the currency format of certain cells on a number of different sheets in one workbook. It works when i run it through tools/macros/ run, but goes into error when i try and run it from a click button, any ideas -- Dave Peterson |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Macro to button | Excel Discussion (Misc queries) | |||
Using Macro to sort without clicking on macro button | Excel Discussion (Misc queries) | |||
Macro Button | Excel Worksheet Functions | |||
use macro button to run macro in protected sheet | Excel Discussion (Misc queries) | |||
How do I use a macro button | Excel Discussion (Misc queries) |