Help with macro

Copper Contributor

Sub junk()
'
' junk Macro
'
' Keyboard Shortcut: Ctrl+j
'
Columns("C:D").Select
Selection.EntireColumn.Hidden = True
Columns("F:G").Select
Selection.EntireColumn.Hidden = True
End Sub

 

This macro hides columns B-K instead of hiding C-D and F-G. I don't understand at all. Can someone help? Thanks!!!!!

1 Reply

@J Ross Jones 

Unless some columns were already hidden, that shouldn't happen. This is the result when I run your macro:

S0761.png

By the way, you can shorten the macro to

Sub junk()
'
' junk Macro
'
' Keyboard Shortcut: Ctrl+j
'
    Range("C1:D1,F1:G1").EntireColumn.Hidden = True
End Sub

Not selecting the ranges that you want to manipulate is more efficient.