![]() |
Hide Columns w/Change Event
I want to hide or show 3 columns depending on the
selection made from a drop-down data validation list. I can only get the column that was selected prior to making a different selection from the list to hide. I don't understand why the columns specified in the code won't hide, so any help I can get with this will be great. Also, this is a worksheet change event; I'm not sure if that's the best way to go with this. Here's the code I've been using; try not to laugh too hard: Sub Worksheet_Change(ByVal Target As Excel.Range) If Application.Intersect(Target, Range("Plan Costs!e1")) = "Hi-Low" Then Exit Sub End If If Application.Intersect(Target, Range("Plan Costs!e1")) = "EDLC" Then Sheets("Period 1").Select Columns("M:O").Select Selection.EntireColumn.Hidden = True End If End Sub |
Hide Columns w/Change Event
Sub Worksheet_Change(ByVal Target As Excel.Range)
If Application.Intersect(Target, Range("Plan Costs!e1")) = "Hi-Low" Then Exit Sub End If If Application.Intersect(Target, Range("Plan Costs!e1")) = "EDLC" Then Sheets("Period 1").Columns("M:O"). _ .EntireColumn.Hidden = True End If End Sub -- Regards, Tom Ogilvy "Eva Shanley" wrote in message ... I want to hide or show 3 columns depending on the selection made from a drop-down data validation list. I can only get the column that was selected prior to making a different selection from the list to hide. I don't understand why the columns specified in the code won't hide, so any help I can get with this will be great. Also, this is a worksheet change event; I'm not sure if that's the best way to go with this. Here's the code I've been using; try not to laugh too hard: Sub Worksheet_Change(ByVal Target As Excel.Range) If Application.Intersect(Target, Range("Plan Costs!e1")) = "Hi-Low" Then Exit Sub End If If Application.Intersect(Target, Range("Plan Costs!e1")) = "EDLC" Then Sheets("Period 1").Select Columns("M:O").Select Selection.EntireColumn.Hidden = True End If End Sub |
Hide Columns w/Change Event
Tom, thanks for the reply, but it's still not working for
me. I'm getting "Method range of object_worksheet failed" error. Help???? -----Original Message----- Sub Worksheet_Change(ByVal Target As Excel.Range) If Application.Intersect(Target, Range("Plan Costs!e1")) = "Hi-Low" Then Exit Sub End If If Application.Intersect(Target, Range("Plan Costs!e1")) = "EDLC" Then Sheets("Period 1").Columns("M:O"). _ .EntireColumn.Hidden = True End If End Sub -- Regards, Tom Ogilvy "Eva Shanley" wrote in message ... I want to hide or show 3 columns depending on the selection made from a drop-down data validation list. I can only get the column that was selected prior to making a different selection from the list to hide. I don't understand why the columns specified in the code won't hide, so any help I can get with this will be great. Also, this is a worksheet change event; I'm not sure if that's the best way to go with this. Here's the code I've been using; try not to laugh too hard: Sub Worksheet_Change(ByVal Target As Excel.Range) If Application.Intersect(Target, Range("Plan Costs!e1")) = "Hi-Low" Then Exit Sub End If If Application.Intersect(Target, Range("Plan Costs!e1")) = "EDLC" Then Sheets("Period 1").Select Columns("M:O").Select Selection.EntireColumn.Hidden = True End If End Sub . |
All times are GMT +1. The time now is 01:26 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com