Showing/Hiding Columns on Sheet 2 based on data validation in Sheet 1

furt0414

New Member
Joined
Jul 17, 2013
Messages
20
Hi All,

I'm new to VBA and could use some help. I have a data validation with Yes and No as the choices on sheet1 and based on the response would like to hide columns AJ:AW on sheet2. I have been digging around the forums for the last hour and haven't come across the answer yet. Can someone help me?

Here's what I have so far in my Sheet1 code:

Private Sub Worksheet_Change(ByVal Target As Range)
With Sheets("Sheet2")
Select Case Target.Address(False, False)
Case "A6"
.Columns("AJ:AW").Columns.Hidden = Target.Value = ""
End Select
End With


End Sub
 

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand
I should also mention that the data validation is in cell C6 on Sheet1, and in cell A6 I have an IF statement that returns "" if C6 = No.
 
Upvote 0
Solved thanks to some creative sleuthing. Here's the solution:

Private Sub Worksheet_Calculate()
Sheet2.Range("AJ:AW").EntireColumn.Hidden = Me.Range("A6") = ""
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,891
Messages
6,122,105
Members
449,066
Latest member
Andyg666

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