auto.pilot
Well-known Member
- Joined
- Sep 27, 2007
- Messages
- 734
- Office Version
- 365
- Platform
- Windows
Using XL 07, cells F1:P1 are populated with the words 'Hide' or 'Show'. The code below simply hides the entire column based on entries in row 1. In addition, I'd like a method to widen each of the 'Show' columns when the macro is run. There are a total of 11 columns. When all 11 are shown, column width should be 8. With 10 shown, column width should be 8.5. With 9 columns shown, width should be 9. For simplicity, let's assume that for each additional hidden column, the width of remaining shown columns should widen by 0.5.
Would appreciate any and all advice.
Thanks
jim
Would appreciate any and all advice.
Thanks
jim
Code:
Sub HideNetGrid()
Application.ScreenUpdating = False
For Each r In Range("F1:P1")
If r.Value = "Hide" Then
r.EntireColumn.Hidden = True
Else
r.EntireColumn.Hidden = False
End If
Next
Application.ScreenUpdating = True
End Sub