GarethCW
New Member
- Joined
- Feb 14, 2024
- Messages
- 3
- Office Version
- 2021
- Platform
- Windows
- MacOS
- Mobile
Hi Could you please assist with the below. macro to hide and unhide various columns. however it does not run correctly, in which columns meant to be hidden are not as well as columns not meant to be hidden are hidden:
VBA Code:
Sub Macro1()
'
' Macro1 Macro
Columns("A:A").Select
Selection.EntireColumn.Hidden = False
Columns("B:B").Select
Selection.EntireColumn.Hidden = False
Columns("C:C").Select
Selection.EntireColumn.Hidden = False
Columns("D:D").Select
Selection.EntireColumn.Hidden = False
Columns("E:E").Select
Selection.EntireColumn.Hidden = False
Columns("F:F").Select
Selection.EntireColumn.Hidden = True
Columns("G:G").Select
Selection.EntireColumn.Hidden = False
Columns("H:H").Select
Selection.EntireColumn.Hidden = False
Columns("I:I").Select
Selection.EntireColumn.Hidden = False
Columns("J:J").Select
Selection.EntireColumn.Hidden = False
Columns("K:K").Select
Selection.EntireColumn.Hidden = False
Columns("L:L").Select
Selection.EntireColumn.Hidden = True
Columns("M:M").Select
Selection.EntireColumn.Hidden = True
Columns("N:N").Select
Selection.EntireColumn.Hidden = True
Columns("O:O").Select
Selection.EntireColumn.Hidden = False
Columns("P:P").Select
Selection.EntireColumn.Hidden = True
Columns("Q:Q").Select
Selection.EntireColumn.Hidden = True
Columns("R:R").Select
Selection.EntireColumn.Hidden = False
Columns("S:S").Select
Selection.EntireColumn.Hidden = False
Columns("T:T").Select
Selection.EntireColumn.Hidden = True
Columns("U:U").Select
Selection.EntireColumn.Hidden = False
Columns("V:V").Select
Selection.EntireColumn.Hidden = False
Columns("W:W").Select
Selection.EntireColumn.Hidden = True
Columns("X:X").Select
Selection.EntireColumn.Hidden = False
Columns("Y:Y").Select
Selection.EntireColumn.Hidden = False
Columns("Z:Z").Select
Selection.EntireColumn.Hidden = True
Columns("AA:AA").Select
Selection.EntireColumn.Hidden = False
Columns("AB:AB").Select
Selection.EntireColumn.Hidden = False
Columns("AC:AC").Select
Selection.EntireColumn.Hidden = True
Columns("AD:AD").Select
Selection.EntireColumn.Hidden = False
Columns("AE:AE").Select
Selection.EntireColumn.Hidden = True
Columns("AF:AF").Select
Selection.EntireColumn.Hidden = True
Columns("AG:AG").Select
Selection.EntireColumn.Hidden = True
Columns("AH:AH").Select
Selection.EntireColumn.Hidden = True
Columns("AI:AI").Select
Selection.EntireColumn.Hidden = True
Columns("AJ:AJ").Select
Selection.EntireColumn.Hidden = False
Columns("AK:AK").Select
Selection.EntireColumn.Hidden = False
Columns("AL:AL").Select
Selection.EntireColumn.Hidden = False
Columns("AM:AM").Select
Selection.EntireColumn.Hidden = False
Columns("AN:AN").Select
Selection.EntireColumn.Hidden = False
Columns("AO:AO").Select
Selection.EntireColumn.Hidden = True
Columns("AP:AP").Select
Selection.EntireColumn.Hidden = False
Columns("AQ:AQ").Select
Selection.EntireColumn.Hidden = True
Columns("AR:AR").Select
Selection.EntireColumn.Hidden = False
Columns("AS:AS").Select
Selection.EntireColumn.Hidden = True
Columns("AT:AT").Select
Selection.EntireColumn.Hidden = False
Columns("AU:AU").Select
Selection.EntireColumn.Hidden = True
Columns("AV:AV").Select
Selection.EntireColumn.Hidden = True
Columns("AW:AW").Select
Selection.EntireColumn.Hidden = True
Columns("AX:AX").Select
Selection.EntireColumn.Hidden = True
Columns("AY:AY").Select
Selection.EntireColumn.Hidden = False
Columns("AZ:AZ").Select
Selection.EntireColumn.Hidden = False
Columns("BA:BZ").Select
Selection.EntireColumn.Hidden = True
End Sub
Last edited by a moderator: