Excel - Macro hide columns not working

Hi Experts,
I have a worksheet that I need to hide certain columns with a macro, and with a second macro hide other columns.
But when ever I try to set the macro to even hide ONE column, it hides the entire table.

Once the macro works then I will need to select the first row, the table, and the last row to fit onto one landscape 8.5 by 11 sheet of paper.

The second macro will also do the same but with a different combination of columns selected.

There is one row above the table and on row under that I will also need to include to print.
When ever I try to macro one column it hides all columns A through AH which is the entire table.

Thanks so much

I have attached the dummy file./
dummy.xlsm
chris pikeAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
NorieConnect With a Mentor VBA ExpertCommented:
The problem is the merged cells in row 38, either unmerge those cells or try something like this.
Sheets("Main file").Columns(3).EntireColumn.Hidden = True

Open in new window

0
 
Martin LissConnect With a Mentor Older than dirtCommented:
ActiveSheet.Range("C1").EntireColumn.Hidden = True
0
 
Martin LissOlder than dirtCommented:
either unmerge those cells or try something like this
Or my solution which has exactly the same effect.
0
 
chris pikeAuthor Commented:
Thank you very much.
I didn't know that a merged cell would mess up the columns.
0
All Courses

From novice to tech pro — start learning today.