I was able to find and write code which hides all specified columns for a report at work that I am slowly trying to automate. The report in question has 20 or so columns and I only really need 8 from the report.
I can easily use the code to write 12 or so lines to hide them. However it seems that it would easier to read and much more efficient to write the inverse of that code. I am fairly new to VBA and this is my first real project I am trying to utilize the language for so its been a mixture of trial and error.
Current Project:
I can easily use the code to write 12 or so lines to hide them. However it seems that it would easier to read and much more efficient to write the inverse of that code. I am fairly new to VBA and this is my first real project I am trying to utilize the language for so its been a mixture of trial and error.
Current Project:
VBA Code:
Sub Hide_Me()
Dim Lastcolumn As Long
Lastcolumn = Cells(3, Columns.Count).End(xlToLeft).Column
For i = 1 To Lastcolumn
If Cells(3, i).Value = "Customer Name" Or Cells(3, i).Value = "Address" Or Cells(3, i).Value = "Phone Number" or ... 'continue to perpetuity
Then Columns(i).Hidden = true
Next
End Sub