Hide or unhide a cell base on text in a different cell - Either VBA or formula solution.

Liam_1988

New Member
Joined
Apr 30, 2020
Messages
25
Office Version
  1. 2013
Platform
  1. Windows
Hi,

I've been using VBA for about 6 months or so (hobbyist). I'm currently working on a workbook for my job and I'm completely stuck.

XABCD
1​
Sent By:
2​
Date Sent:
3​
Method:Tracking #:

I have the above in place. I'm trying to have it so that C3 & D3 are hidden unless B3 (which has a Data Validation list assigned to it) says "Postal".

I don't mind if this achieved with a Formula or VBA.

Please Please help it's driving me crazy!
 

Excel Facts

Which Excel functions can ignore hidden rows?
The SUBTOTAL and AGGREGATE functions ignore hidden rows. AGGREGATE can also exclude error cells and more.
You cannot hide individual cells, only entire rows/columns.
 
Upvote 0
How about
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
   If Target.CountLarge > 1 Then Exit Sub
   If Target.Address(0, 0) = "B3" Then
      Rows(4).Hidden = Not Target.Value = "Postal"
   End If
End Sub
This needs to go in the relevant sheet module.
 
Upvote 0
Thanks Fluff.

Unfortunately there was an error with "If Target.CountLarge > 0 Then Exit Sub".
 
Upvote 0
Is there command that's basically if B3 = postal then unhide otherwise hide in any other circumstance.

If it helps the only other cell values can be:
- "Email"
- "Portal"
or Blank
 
Upvote 0
You said you were getting an error on this line "If Target.CountLarge > 0 Then Exit Sub"
That is not what I suggested.
What is the code you are using?
 
Upvote 0
I tried:

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.CountLarge > 1 Then Exit Sub
If Target.Address(0, 0) = "D83" Then
Rows(87).Hidden = Not Target.Value = "Postal"
End If
End Sub

and

If Target.CountLarge > 1 Then Exit Sub
If Target.Address(0, 0) = "D83" Then
Rows(87).Hidden = Not Target.Value = "Postal"
End If
End Sub
You said you were getting an error on this line "If Target.CountLarge > 0 Then Exit Sub"
That is not what I suggested.
What is the code you are using?
 
Upvote 0

Forum statistics

Threads
1,214,936
Messages
6,122,340
Members
449,079
Latest member
rocketslinger

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