Am wanting to have a macro/button that toggles between hiding and unhiding select columns. I had something similar that hid/unhid rows but can't figure this one out.
Sub PrintToggle()
With ActiveSheet
With Range("C:C,E:E,H:H,L:O,U:U,AA:AA,AF:AF,AI:AK").Columns
If .EntireColumn.Hidden Then
.EntireColumn.Hidden = False
Else
.EntireColumn.Hidden = True
End If
End With
End With
End Sub
This use to at least hide the columns but after saving and re-opening, it now hides the entire sheet. I can't get it to stop doing this let along unhide the same columns. Thanks!
.Columnsis redundant but otherwise works fine for me. - BigBen.in front ofRange, or just get rid of theWith ActiveSheetbtw. - BigBenDebug.Print ActiveSheet.Range("A:A,C:C").Address, I getApplication-defined or object-defined error(1004). But when I do thisDebug.Print Range("A:A,C:C").AddressI getMethod 'Range' of object '_Global' failed(1004). But I figured out that I need to use the semi-colon (;) instead of the comma. - VBasic2008