Home |
Search |
Today's Posts |
|
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
LAST value of loop to be a variable
Hi all.
Consider the following: Sub Macro41() ' Print ALL Dim x As Integer For x = 1 To 5 Call Over7A Application.Run ("Macro" & x) Call Last7A Next x End Sub I want the number 5 (the final value of the loop) to be the contents of cell C2 of the current sheet of a file named €˜Name List.xls. Can Anybody Help? |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
LAST value of loop to be a variable
We don't need to know the current sheet in Name List, just go there and come
back: Workbooks("Name List.xls").Activate n = Range("C2").Value Workbooks("Book1.xls").Activate For x = 1 To n .. .. .. -- Gary''s Student - gsnu200760 "Berj" wrote: Hi all. Consider the following: Sub Macro41() ' Print ALL Dim x As Integer For x = 1 To 5 Call Over7A Application.Run ("Macro" & x) Call Last7A Next x End Sub I want the number 5 (the final value of the loop) to be the contents of cell C2 of the current sheet of a file named €˜Name List.xls. Can Anybody Help? |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
LAST value of loop to be a variable
maybe
Sub Macro41() myvar = Workbooks("Name List.xls").ActiveSheet.Range("C2") Dim x As Integer For x = 1 To myvar 'do your stuff Next x End Sub Mike "Berj" wrote: Hi all. Consider the following: Sub Macro41() ' Print ALL Dim x As Integer For x = 1 To 5 Call Over7A Application.Run ("Macro" & x) Call Last7A Next x End Sub I want the number 5 (the final value of the loop) to be the contents of cell C2 of the current sheet of a file named €˜Name List.xls. Can Anybody Help? |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Loop with variable name? | Excel Discussion (Misc queries) | |||
loop for-next with variable end | Excel Programming | |||
Loop and variable type | Excel Programming | |||
For Each ... Next loop - need to reference the loop variable | Excel Programming | |||
Loop with variable | Excel Programming |