Macro stopped running

matthewlouis

Active Member
Joined
Mar 28, 2014
Messages
374
Office Version
  1. 365
  2. 2019
Platform
  1. Windows
When I open worksheet, there is a macro that is supposed to run. When I hit Alt F11, the box is grayed out with no code.

I don't code, just a formula guy, this was a macro someone here on the board helped me with. So I am dense on coding. But this is a great macro.

When I open the worksheet, I am not asked anything. I went to File>Info> and the Security Information is not restricting (I trust the source).

What happened to the macro and why is the box grayed out and no code is there?

Thanks in advance!
 

Excel Facts

Format cells as time
Select range and press Ctrl+Shift+2 to format cells as time. (Shift 2 is the @ sign).
You might improve your chances of getting an answer if you post the code (macro) you reference.
 
Upvote 0
Sub clicky()
For t = 1 To 100
Application.Calculate
Range("J10").Value = Range("J10").Value + 1
If Range("k2").Value <= 0.8 Then Range("J12").Value = Range("J12").Value + 1
Debug.Print t & ":" & Range("k2")
MsgBox t
Next t
End Sub


THIS is highlighted in yellow (like there is an error) . . . If Range("k2").Value <= 0.8
 
Upvote 0
It runs 100 tests to see how many passed and how many failed.
 
Upvote 0
Sub clicky()
For t = 1 To 100
Application.Calculate
Range("J10").Value = Range("J10").Value + 1
If Range("k2").Value <= 0.8 Then Range("J12").Value = Range("J12").Value + 1
Debug.Print t & ":" & Range("k2")
MsgBox t
Next t
End Sub


THIS is highlighted in yellow (like there is an error) . . . If Range("k2").Value <= 0.8
The code you posted won't run by itself when you activate the worksheet. Is there a button you click to run the macro .... or is there a worksheet_activate event code in the sheet?
 
Upvote 0
Well, I just copied and pasted the macro that was in the code. Whenever I opened worksheet, it would run. It isn't now. I have no idea why it stopped.
 
Upvote 0
Well, I just copied and pasted the macro that was in the code. Whenever I opened worksheet, it would run. It isn't now. I have no idea why it stopped.
Do you mean "opened the workbook" or "go to a specific worksheet"?
(That nomenclature is critical here, as VBA code can run automatically when a workbook is first opened and/or when a worksheet is first activated).

If you go into your VB Editor, do you see any VBA code in the "ThisWorkbook" module?
How about any VBA code in the particular sheet module that your data resides in?

This link shows you where you can see those VBA modules: What is a VBA Module? - Automate Excel
 
Upvote 0
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
100​
ALT + F11
Ctrl-S
100​
Let it run
Alt-Q
Alt-F8
Hit Run
Alt-G opens up Immediate Box
To Calculate, hit CTR-SHIFT-C then ESC
 
Upvote 0

Forum statistics

Threads
1,216,077
Messages
6,128,685
Members
449,463
Latest member
Jojomen56

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