montypython1
Technical User
Greetings,
Can anyone tell me why I can't use an Excel macro to hide or unhide certain columns within my Excel spreadsheet?
I can manually hide or unhide these columns, but when I try to record the keystrokes using an Excel macro, it ends up hiding almost ALL of the columns (it only shows columns A,B,U). I even tried placing a wait command within the VBA script to try to slow down the execution:
But this only served to slow down the end result.
Below is the VBA code. You can see that I am selecting and unhiding all columns, then hiding certain columns. It works when I do this manually, but not when I run it in a macro:
For years, I have been able to record my keystrokes and my formatting without any problems. What am I missing?
Thanks,
Dave
Can anyone tell me why I can't use an Excel macro to hide or unhide certain columns within my Excel spreadsheet?
I can manually hide or unhide these columns, but when I try to record the keystrokes using an Excel macro, it ends up hiding almost ALL of the columns (it only shows columns A,B,U). I even tried placing a wait command within the VBA script to try to slow down the execution:
Code:
Application.Wait Now + TimeValue("00:00:03")
Below is the VBA code. You can see that I am selecting and unhiding all columns, then hiding certain columns. It works when I do this manually, but not when I run it in a macro:
Code:
Sub CFS_Show_Gross()
'
' CFS_Show_Gross Macro
'
Cells.Select
Selection.EntireColumn.Hidden = False
Range("C:D,F:H,J:L,N:P,R:R").Select
Range("R3").Activate
Selection.EntireColumn.Hidden = True
Range("S:T,V:AE").Select
Range("V1").Activate
Selection.EntireColumn.Hidden = True
Range("C10").Select
End Sub
For years, I have been able to record my keystrokes and my formatting without any problems. What am I missing?
Thanks,
Dave