Hide Columns Based on Other Sheet Cell Value

VrRotate

New Member
Joined
Mar 11, 2022
Messages
9
Office Version
  1. 365
Platform
  1. Windows
Hello,

I've used several examples and can't get this to work.

Condition:
Drop down on Sheet1 cell B7 Yes or No

If No hide Sheet2 Columns CN - EL
If Yes show Sheet2 Columns CN - EL

Want to work in real time as user selects Yes or No, if that's possible?

Thank you in advance for all your help!
 
So you mean 1,048,576 Ns in each column?
 
Upvote 0

Excel Facts

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.
Is there any column that will always have data on the last used row?
 
Upvote 0
Try:
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    If Target.CountLarge > 1 Then Exit Sub
    If Intersect(Target, Range("B7")) Is Nothing Then Exit Sub
    Dim LastRow As Long
    LastRow = Cells.Find("*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
    Select Case Target.Value
        Case "Yes"
            Sheets("Sheet2").Columns("CN:EL").Hidden = False
            Sheets("Sheet2").Range("CN2:EL" & LastRow).ClearContents
        Case "No"
            Sheets("Sheet2").Range("CN2:EL" & LastRow) = "N"
            Sheets("Sheet2").Columns("CN:EL").Hidden = True
    End Select
End Sub
 
Upvote 0
So I just realized this is working well except its stopping the "N" after row 18...any ideas?
 
Upvote 0

Forum statistics

Threads
1,224,835
Messages
6,181,247
Members
453,026
Latest member
cknader

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