MACRO in a Loop Problem

  • Thread starter Thread starter Berj
  • Start date Start date
B

Berj

Dear Anybody.

Consider this code:

Sub Macro41()
' Print ALL

Dim counter As Integer
For counter = 1 To 5
Call Over
Call Macro(counter)
Call Last
Next counter

End Sub

A few problems-
1. I want to address Macro1, Macro2, Macro3 … but it it gives me an error on
the Call Macro line. How can I make it work?
2. I want the number 5 (final value of the loop) to be the contents of C2
cell of the current sheet and file the Macro41 is in.


Thanks in Advance.
 
Use this, substitute your macro number for x

Application.Run ("Macro" & x)
 
Thanks.
I used the following, and the loop worked fine.


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

But still I have this problem of the number 5 (the final value of the loop).
I want the number 5 to be the contents of cell C2 of the current sheet of a
file named ‘Name List.xls’.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

LAST value of loop to be a variable 2
How to hide password? 1
Loop without Do 2
Do Until or For Loop 3
Macro creation via VBA 26
Can't make loop macro work - help? 1
help with a piece of code 5
Macro conflict 4

Back
Top