Recording a macro in Excel to hide columns

Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

prephil

Thread Starter
Joined
Feb 9, 2007
Messages
53
I work on parts lists at work that have ben created by colleagues. They have approximately 80 columns. I need to refer to these parts lists when completing a separate excel file and I want to be able to hide certain columns. The columns that I want to hide are not beside each other so I can't use the *group* function. Well I suppose I could use it but I’d prefer to use a Macro as I'm sure it would be moe efficient.

I’m not up to speed with VBA and I’ve been attempting to record a Macro but have only been partially successful thus far. So on the attached is my macro recording effort. I wanted to hide columns G, T, AC, AF, AX and BA. In order to do this I am doing the following
  1. View Tab > Record Macro
  2. Enter macro name and description
  3. Shift select columns G, T, AC, AF, AX and BA
  4. Right click and hide them
  5. Click on Stop Recording
I thought this would be sufficient. However, when I go back and run the macro it hides columns A:L, T, AC, AF, AX and BA. Can anyone show me what I’m doing wrong or is my understanding of how a macro works different to reality.

Moving on from this I would like to be able to do the opposite, i.e. unhide above columns (actually this macro works in the attached). Would also be very handy to have buttons that I could just click on that would do this.
 

Attachments

Joined
Sep 4, 2003
Messages
4,916
This is happening because you have merged cells on row 1. If you get rid of the merged cells or delete the entire 1st row completely it should work for you the way you intend.

Regards,
Rollin
 
Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 807,865 other people just like you!

Latest posts

Staff online

Members online

Top