VBA Worksheet_Calculate() Code doesn't run until it is run from VB Editor

silverfang

New Member
Joined
Mar 19, 2020
Messages
11
Office Version
  1. 2016
  2. 2010
Platform
  1. Windows
I have a working code, but it doesn't hide until i Run the code from VB Editor :

Maybe those D3,D4 and D5 are formulated , that's why it is not running on its own :
The above code isto run the formula in cells in CheckList sheet so that they take in values from the drop down list.

This code hides only one option from the drop down Sheet "FSSAI WS", but then other ones are not responding until and unless i press the RUN option in VB Editor.

Can someone please help me out......!!!


VBA Code:
Sub Formula_Property()

Range("D3").Formula = "='FSSAI WS'!D13"
Range("D4").Formula = "='FSSAI WS'!F13"
Range("D5").Formula = "='FSSAI WS'!D15"

End Sub

------------------------------------------------------------------------------------------------------------------------
Private Sub Worksheet_Calculate()

'Application.ScreenUpdating = False
Application.EnableEvents = False


Dim business As Range
Set business = Sheets("Checklist").Range("D4")

Select Case business
        Case Is = "Manufacturer": Rows("10:14").EntireRow.Hidden = True
        Case Is = "Trader": Rows("16:18").EntireRow.Hidden = True
        Case Is = "Relabeller & Repackers": Rows("20:25").EntireRow.Hidden = True
        Case Is = "--": Rows("10:30").EntireRow.Hidden = False

'Application.ScreenUpdating = True
Application.EnableEvents = True

End Select
End Sub
 

Excel Facts

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).
Have you tried it using :

Private Sub Worksheet_SelectionChange(ByVal Target As Range)

or

Private Sub Worksheet_Change(ByVal Target As Range)
 
Upvote 0
Two things to consider:

1. This line of code here:
VBA Code:
Application.EnableEvents = False
temporarily disables events while the code is being run, so the code doesn't make changes, call itself, and get caught in an infinite loop.
You turn it back on at the end with this line:
VBA Code:
Application.EnableEvents = True
However, if in the process of working on it, it shuts it off, and then gets interrupted, and never gets to the line at the end to turn it back on, it won;t work automatically for you. You need to turn it back on. You can do that by manually running this:
VBA Code:
Sub TurnEventsOn()
    Application.EnableEvents = True
End Sub

2. This runs when a calculation is done on your sheet. However, if you have calculations set to manual, then it won't run until you manually run a Calculation.
 
Upvote 0
Yes Sir, i tried with them both.
Those don't change a thing at all.
Since

Maybe those D4 is formulated , that's why it is not running on its own.
My code was running until yesterday, today idk(bad luck i suppose).
 
Upvote 0
@Joe4 - Sir, there was no error in my code until yesterday. today i have tried all combinations and still nothing comes up correctly.
 
Upvote 0
" My code was running until yesterday, "

Confused ... did you change the formulas or are things still the way they were a few days ago ?
If things remain the same ... something else is going on than your code.

????
 
Upvote 0
" My code was running until yesterday, "

Confused ... did you change the formulas or are things still the way they were a few days ago ?
If things remain the same ... something else is going on than your code.

????
I haven't changed a bit of the code.
 
Upvote 0
What is your intention, of which the code should run?

The two procedures you posted in your first post, which modules are those found in?
 
Upvote 0

Forum statistics

Threads
1,224,820
Messages
6,181,157
Members
453,021
Latest member
Justyna P

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