Since you are deactivating worksheet, the default worksheet becomes the active worksheet that you swithced to, so when using ranges without sheet reference, i.e. Columns("A:K")
, they refer to columns in current worksheet. That's why you should always use references to worksheets, i.e.
Dim ws As Worksheet
Set ws = Worksheets("reference")
And then use it to reference ranges in it:
ws.Columns("A:K").EntireColumn.Hidden = True
Not that I got rid out of the Select
method, which is very discouraged to use.
This might be really helpful for you: How to avoid using Select in Excel VBA