Macro Doesn't Run Automatically

matthewlouis

Active Member
Joined
Mar 28, 2014
Messages
374
Office Version
  1. 365
  2. 2019
Platform
  1. Windows
Several months ago, I had some help creating the following macro.

Sub clicky()
For t = 1 To 100
Application.Calculate
Range("J10").Value = Range("J10").Value + 1
If Range("F11").Value <= 0.8 Then Range("J12").Value = Range("J12").Value + 1
Debug.Print t & ":" & Range("F11")
MsgBox t
Next t
End Sub

The macro works well except for one thing. It doesn't run automatically. When I hit CTRL-Shift-C, I want it to run the macro automatically 100 times. However, I am having to hit the Esc button each time to run ONE simulation, or 100 times to complete it. Am I missing a line in the code? I circled back to the person who helped write this code but I never heard back from him . . . it's been 3 months . . . so I hope the moderators understand this isn't a re-post.

Thanks in advance!


Several months ago, I had some help
 

Excel Facts

Excel motto
Not everything I do at work revolves around Excel. Only the fun parts.
Have you tried getting rid of these two lines?
VBA Code:
Debug.Print t & ":" & Range("F11")
MsgBox t
I think they may just for demonstation purposes and may not be needed, and probably require you to do respond each time it comes to those lines.
 
Upvote 0
Solution
Have you tried getting rid of these two lines?
VBA Code:
Debug.Print t & ":" & Range("F11")
MsgBox t
I think they may just for demonstation purposes and may not be needed, and probably require you to do respond each time it comes to those lines.
Yessir!!! That did it, thanks so much!
 
Upvote 0
Actually . . . that didn't work.

While it did process all 100 simulations at one time, it messed up the calcualtion . . . it failed to calculate the Failures vs, Successful . . . it made all of them positive.
 
Upvote 0
While it did process all 100 simulations at one time, it messed up the calcualtion . . . it failed to calculate the Failures vs, Successful . . . it made all of them positive.
I have no idea of what any of that is/means.
All you really provided was the code, without any data or explanation of what this is and how it works.
You just asked why it doesn't run all the loops automatically, and I explained why.

It sounds like you have a design and/or logic issues.
 
Upvote 0
I have no idea of what any of that is/means.
All you really provided was the code, without any data or explanation of what this is and how it works.
You just asked why it doesn't run all the loops automatically, and I explained why.

It sounds like you have a design and/or logic issues.
Sorry, I wasn't clear about that.

Basically, the algo gives a probability of success and failure using stock market data. That wasn't important to the "automatic" problem in the algo . . . until I deleted those two lines you suggested. Well, it is important because while it did automatically run it 100 times. However, F11 is a cell reference and must be important because by deleting it as part of the tow lines, it did change the algo's calculation.
 
Upvote 0
@Joe4 a bit more info in what I believe was the original post (based on the last post in the old thread) the OP mentions.
 
Upvote 0
I have zero experience with donut/pivot charts, so I don't think I will be much help on this.

Since the question now is different than the original question, I suggest you start a new thread so that it appears as a new unanswered question, and might get more attention.
Be sure to include ALL the pertinent details in the question, so people understand the full scope of what you are trying to do.
 
Upvote 0

Forum statistics

Threads
1,214,982
Messages
6,122,580
Members
449,089
Latest member
Motoracer88

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