![]() |
Hide column depending on its header
Hi there,
I am new to VBA and seeking help. I am basically needing to hide all range columns with exception of columns whose headers are that of East Coast cities. How do I accomplish this? Thanks -- Nashlow |
Hide column depending on its header
Hi Nashlow,
Try: '============= Public Sub Tester003() Dim Col As Range Dim arrCities As Variant arrCities = Array("City1", "City2", "City3", "City4", "City5") For Each Col In ActiveSheet.UsedRange.Columns If IsError(Application.Match _ (Col.Cells(1).Value, arrCities, 0)) Then Col.Hidden = True End If Next Col End Sub '<<============= Replace City1 ...City5 with the required city names. --- Regards, Norman "Nashlow" wrote in message ... Hi there, I am new to VBA and seeking help. I am basically needing to hide all range columns with exception of columns whose headers are that of East Coast cities. How do I accomplish this? Thanks -- Nashlow |
Hide column depending on its header
Thanks Norman,
Code works perfect. It took me so far a week and you have saved me probably more! Great stuff. -- Nashlow "Norman Jones" wrote: Hi Nashlow, Try: '============= Public Sub Tester003() Dim Col As Range Dim arrCities As Variant arrCities = Array("City1", "City2", "City3", "City4", "City5") For Each Col In ActiveSheet.UsedRange.Columns If IsError(Application.Match _ (Col.Cells(1).Value, arrCities, 0)) Then Col.Hidden = True End If Next Col End Sub '<<============= Replace City1 ...City5 with the required city names. --- Regards, Norman "Nashlow" wrote in message ... Hi there, I am new to VBA and seeking help. I am basically needing to hide all range columns with exception of columns whose headers are that of East Coast cities. How do I accomplish this? Thanks -- Nashlow |
All times are GMT +1. The time now is 02:07 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com