Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Variable Macro
Trying again, I am looking for a way to create a variable macro or a macro that contains a variable. I want the macro to acquire a variable number (X) and then run a macro X times. Ex - Macro "Print" 'print Hello and move down one cell; cell a1 = 3 (the variable #), so the new macro would = run "Print 3 times" = Hello Hello Hello Thanks to those who have helped before and to any additional help. |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Variable Macro
Sub MyPrint()
ActiveCell.Value = "Print" ActiveCell.Offset(1,0) End Sub sub ValueMacro() Dim x as Variant Range("A1").Value = 3 x = Range("A1").Value if not isnumeric(x) then exit sub range("C3").Select for i = 1 to x MyPrint Next End Sub -- Regards, Tom Ogilvy "Ronbo" wrote in message ... Trying again, I am looking for a way to create a variable macro or a macro that contains a variable. I want the macro to acquire a variable number (X) and then run a macro X times. Ex - Macro "Print" 'print Hello and move down one cell; cell a1 = 3 (the variable #), so the new macro would = run "Print 3 times" = Hello Hello Hello Thanks to those who have helped before and to any additional help. |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Variable Macro
-----Original Message----- Sub MyPrint() ActiveCell.Value = "Print" ActiveCell.Offset(1,0) End Sub sub ValueMacro() Dim x as Variant Range("A1").Value = 3 x = Range("A1").Value if not isnumeric(x) then exit sub range("C3").Select for i = 1 to x MyPrint Next End Sub -- Regards, Tom Ogilvy "Ronbo" wrote in message ... Trying again, I am looking for a way to create a variable macro or a macro that contains a variable. I want the macro to acquire a variable number (X) and then run a macro X times. Ex - Macro "Print" 'print Hello and move down one cell; cell a1 = 3 (the variable #), so the new macro would = run "Print 3 times" = Hello Hello Hello Thanks to those who have helped before and to any additional help. . Thanks a lot. With a little tweaking it works perfect. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Macro for variable picture | Excel Discussion (Misc queries) | |||
Variable Macro | Excel Discussion (Misc queries) | |||
Range used in a macro needs to be variable | Excel Worksheet Functions | |||
Help with macro formula and variable | Excel Worksheet Functions | |||
Variable Macro | Excel Programming |