Solved

Excel - Macro hide columns not working

Posted on 2016-11-17
4
42 Views
Last Modified: 2016-11-17
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
0
Comment
Question by:chris pike
  • 2
4 Comments
 
LVL 47

Assisted Solution

by:Martin Liss
Martin Liss earned 250 total points
ID: 41891943
ActiveSheet.Range("C1").EntireColumn.Hidden = True
0
 
LVL 33

Accepted Solution

by:
Norie earned 250 total points
ID: 41891964
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
 
LVL 47

Expert Comment

by:Martin Liss
ID: 41892024
either unmerge those cells or try something like this
Or my solution which has exactly the same effect.
0
 

Author Closing Comment

by:chris pike
ID: 41892175
Thank you very much.
I didn't know that a merged cell would mess up the columns.
0

Featured Post

Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Some code to ensure data integrity when using macros within Excel. Also included code that helps secure your data within an Excel workbook.
This Micro Tutorial will demonstrate on a Mac how to change the sort order for chart legend values and decrpyt the intimidating chart menu.
This Micro Tutorial will demonstrate the scrolling table in Microsoft Excel using the INDEX function.

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question