Hiding and showing columns in one operation

jh9940

New Member
Joined
Jul 18, 2024
Messages
9
Office Version
  1. 365
Platform
  1. Windows
Hi

I'd like to open up a range of columns but then hide certain columns within the same range within one operation. This is my current formula but it says mismatch:

Sub CloseAR1KS3()
Columns("X:GU").Hidden = False
Columns("C:D,Y:Z,AD:AO,AQ:AW,AY:BK,BM:BS,BU:BW,BY:CA,CC:CE,CG:CQ,CS:CU,CW:DC,DE:DK,DM:DO,DQ:DW,DY:GU").Hidden = True
Activate.EntireColumn.Hidden = True
End Sub

It's for learner grades which are entered three times a year - so I will eventually have three separate macros that will only show certain columns
Many thanks in advance
 

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.
Hello,
I think it is the last row "Activate.EntireColumn.Hidden = True" that poses problem. It is incorrect, activate is nothing ?
If you want to refer to the selected cell, change this row to
VBA Code:
Selection.EntireColumn.Hidden = True
 
Upvote 0
For non-contiguous columns try using Range
VBA Code:
Sub CloseAR1KS3()
Columns("X:GU").Hidden = False
Range("C:D,Y:Z,AD:AO,AQ:AW,AY:BK,BM:BS,BU:BW,BY:CA,CC:CE,CG:CQ,CS:CU,CW:DC,DE:DK,DM:DO,DQ:DW,DY:GU").EntireColumn.Hidden = True
End Sub
 
Upvote 0
Solution

Forum statistics

Threads
1,225,477
Messages
6,185,221
Members
453,283
Latest member
Shortm88

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top