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
 
@Joe4

I'm trying to hide/unhide rows based on the cell values from selected list in another sheet. My scenario : I have 2 sheets FSSAI and Checklist.
From FSSAI , i need to select from drop down list from cells D13 , F13 and D15, then once these values are selected , they go to Checklist's D3 , D4 and D5 respectively.
As they are going to D3,D4 and D5 , the Rows between (9:38) should be keep on hiding the way. Any combination of D3,D4 and D5 should yield in what i intend to do hide.
And when i select "--", all the fields should be un-hidden.

The above code was to run the formula in cells in CheckList sheet so that they take in values from the drop down list.

See both the images of sheet 1(FSSAI ) and Sheets 2(Checklist)
 

Attachments

  • FSSAI-Sheet1.PNG
    FSSAI-Sheet1.PNG
    32.4 KB · Views: 15
  • Checklist-Sheet2.PNG
    Checklist-Sheet2.PNG
    95.2 KB · Views: 14
Upvote 0

Excel Facts

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.
You didn't answer the second question I had:
The two procedures you posted in your first post, which modules are those found in?
Namely, I need to know the name of the VB module you have placed the Worksheet_Calculate code in.
 
Upvote 0
You didn't answer the second question I had:

Namely, I need to know the name of the VB module you have placed the Worksheet_Calculate code in.
Oops sorry.
The Procedures are in the checklist(Sheet2).
The code as well the worksheet_calculate() event both are in sheet's "view Code" and not in a module.
 
Upvote 0
i need to select from drop down list from cells D13 , F13 and D15, then once these values are selected
Are D13, F13, and D15 on the "FSSAI WS" worksheet manually updated (by someone manually selecting an option from the drop-down list)?
If so, then use a Worksheet_Change event procedure on the "FSSAI WS" sheet instead, i.e.
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)

'   Only run when cell F13 is updated
    If Target.Address(0, 0) = "F13" Then
    
        Select Case Target.Value
            Case Is = "Manufacturer": Sheets("Checklist").Rows("10:14").EntireRow.Hidden = True
            Case Is = "Trader": Sheets("Checklist").Rows("16:18").EntireRow.Hidden = True
            Case Is = "Relabeller & Repackers": Sheets("Checklist").Rows("20:25").EntireRow.Hidden = True
            Case Is = "--": Sheets("Checklist").Rows("10:30").EntireRow.Hidden = False
        End Select
        
    End If
    
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,178
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