Hide Columns Based on Cell in Antoher Tab

kw127533

New Member
Joined
Jul 14, 2014
Messages
3
Hi There,

I'm looking to hide columns AD, AF, AH & AJ on sheet DC Project if cell B13 from the Contacts sheet is equal to no or blank. If it is yes I want to show all of those columns. Can someone please help?? I can't figure out how to code it based on multiple sheets. This is what I have so far (in the Contacts sheet coding):

Private Sub Worksheet_Change(ByVal target As Range)
If Range("B13").Value = "No" Then
Cell is populated, Make row 4 on "DC Projects" hidden
Sheets("DC Project").Columns("ad").EntireColumn.Hidden = True
'Sheets("DC Project").Columns("af").EntireColumn.Hidden = True
Sheets("DC Project").Columns("ah").EntireColumn.Hidden = True
Sheets("DC Project").Columns("aj").EntireColumn.Hidden = True
Else
Cell is empty, Make row 4 on "DC Projects" unhidden
Sheets("DC Project").Columns("ad").EntireColumn.Hidden = False
Sheets("DC Project").Columns("af").EntireColumn.Hidden = False
Sheets("DC Project").Columns("ah").EntireColumn.Hidden = False
Sheets("DC Project").Columns("aj").EntireColumn.Hidden = False
End If
End Sub
 
Last edited:
I think this might work
Code:
Private Sub Worksheet_Change(ByVal target As Range)
 If Range("B13").Value = "Yes" Then
	 'Cell is empty, Make row 4 on "DC Projects" unhidden
 	Sheets("DC Project").Columns("ad").EntireColumn.Hidden = False
 	Sheets("DC Project").Columns("af").EntireColumn.Hidden = False
 	Sheets("DC Project").Columns("ah").EntireColumn.Hidden = False
 	Sheets("DC Project").Columns("aj").EntireColumn.Hidden = False
Else
 	'Cell is populated, Make row 4 on "DC Projects" hidden
 	Sheets("DC Project").Columns("ad").EntireColumn.Hidden = True
 	Sheets("DC Project").Columns("af").EntireColumn.Hidden = True
 	Sheets("DC Project").Columns("ah").EntireColumn.Hidden = True
 	Sheets("DC Project").Columns("aj").EntireColumn.Hidden = True
 End If
 End Sub
Don't understand the comments about row 4.
 
Upvote 0
Try this:

Code:
Sub KW()

If Sheets("Contacts").Range("B13") = "" Or Sheets("Contacts").Range("B13") = "no" Then
    Sheets("DC Projects").Range("AD1,AF1,AH1,AJ1").EntireColumn.Hidden = True
Else
    Sheets("DC Projects").Range("AD1,AF1,AH1,AJ1").EntireColumn.Hidden = False
End If

End Sub
 
Upvote 0

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