Problem with Worksheet_Calculate() / Worksheet_Change()

Brett Thompson

New Member
Joined
Oct 5, 2020
Messages
4
Office Version
  1. 365
Platform
  1. Windows
Hello all
Hoping for some help on a simple workbook we would like to put together...
Using a combo box from form control; we would like the 'cell link' value, derived from the value selected in the combo box, to automatically trigger a macro. As a concept, the workbookcurrently has 2 macros, but there would be more when finished.
When I point the VBA at a manually changing cell, the macros run & hide / unhide the columns as excepted, but we can't get it to work from the result of the combo box.
VBA Code:
Sub ReEnableEvents()
    Application.EnableEvents = True
End Sub


Sub Worksheet_Calculate()
    Dim target As Range
    Set target = Range("D2")
    If Not Intersect(target, Range("D2")) Is Nothing Then
    End If
    If target.Value = 1 Then
    Call ShowAll
    End If
    If target.Value = 2 Then
    Call ShowHandS
    End If
End Sub
Hope this makes sense? Thanks for reading & any questions, please ask...

Many thanks
B
 
Last edited by a moderator:

Excel Facts

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.
Why not assign a macro to the form control directly?
 
Upvote 0
Thanks Rory.

I'd put that down to a severe lack of knowledge on my part. How would I do that?

Cheers
B
 
Upvote 0
Sorry, Rory...Just to add. I'm not sure how you assign conditional macros to form control. I can see how a single macro can be assigned...

B
 
Upvote 0
You'd create a macro that has the conditions in it - for example:

VBA Code:
Sub CheckValue()
If Range("D2").Value = 1 Then
Call ShowAll
ElseIf Range("D2").Value = 2 Then
Call ShowHandS
    End If
End Sub
 
Upvote 0
Glad to help. :)
 
Upvote 0

Forum statistics

Threads
1,214,643
Messages
6,120,702
Members
448,980
Latest member
CarlosWin

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