Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 36
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default 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   Report Post  
Posted to microsoft.public.excel.programming
No Name
 
Posts: n/a
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro for variable picture _Nate Excel Discussion (Misc queries) 1 December 12th 07 05:31 PM
Variable Macro Heather O'Malley Excel Discussion (Misc queries) 2 August 2nd 06 04:19 PM
Range used in a macro needs to be variable DaveP Excel Worksheet Functions 3 November 4th 05 03:23 PM
Help with macro formula and variable Huge project Excel Worksheet Functions 0 December 28th 04 01:27 AM
Variable Macro Ronbo Excel Programming 3 June 24th 04 01:53 AM


All times are GMT +1. The time now is 10:41 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"