VB Code not applying

_KerMit_

New Member
Joined
Jan 2, 2024
Messages
1
Office Version
  1. 365
Platform
  1. Windows
Hi,
Hopefully this is a quick easy one, and I'm missing something very simple here!

I have multiple tabs in an excel and in Sheet4 I have VB Code to hide certain rows depending on Value of Cell B3 on Sheet4
The VB Code applies whenever I manually change the Value of Cell B3 on Sheet4, however the problem arises when B3 is changed to reference a Value from another Sheet, the VB Code no longer applies.....
Is there a simple change I could apply to the code (picture attached) to account for this, else is there a Refresh Button I could create which would apply the Code after the Value updated?

Appreciate any help or guidance!
 

Attachments

  • Excel VB Code.PNG
    Excel VB Code.PNG
    168.4 KB · Views: 5

Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.
When asking about code it is much better to paste your actual code into the post and mark it as code using the VBA button, rather than posting a picture of your code. Then we can copy, test, and modify your code easily without typing it in from scratch.

Worksheet_Change occurs only when the content of a cell is changed, not when the result of a formula changes. You could try using Worksheet_Calculate, which occurs whenever the worksheet is recalculated. Then you would eliminate the If and End If lines and just do
VBA Code:
Select Case [B3].Value

Also, just FYI, your Intersect argument is needlessly self-referential. Instead of Range(Target.Address) you can just use Target.
 
Upvote 0
Solution

Forum statistics

Threads
1,215,069
Messages
6,122,954
Members
449,095
Latest member
nmaske

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