How to call Macro specific Number of times

  • Thread starter Thread starter Legacy 185509
  • Start date Start date
L

Legacy 185509

Guest
Hi
I am trying to run a loop like 16 times
is there any way I can do it please help me
thank you so much
 
What do you have in R1? It has to be a number. Not a number stored as text, text or an error value.
 
Upvote 0

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.
oh oky it was calculated value but I tried with like real number 2
it still doesn't work
 
Upvote 0
it works if I do this
Code:
Sub Run()
For i = 1 To Sheets("Sheet1").Range("R1").Value
    Call Second_Run
Next i
End Sub
but it does extra run :(
 
Upvote 0
R1 = 2 <-- without any formula,

and after adding Sheets("Sheet1").Range("R1").Value
it still works if I have
R1 = 1+1 = 2
or
R1 = E5/7 = some number



---
I think it is doing initial run 1 once always thats why
and it is calling second run how ever many times in this case 2 so = 3
 
Last edited by a moderator:
Upvote 0
Try

Rich (BB code):
Sub MyRun()
For i = 1 To CLng(Sheets("Sheet1").Range("R1").Value)
    Call Second_Run
Next i
End Sub

Run is a reserved word.
 
Upvote 0

Forum statistics

Threads
1,224,621
Messages
6,179,941
Members
452,949
Latest member
beartooth91

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top