1. Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members.

Recording a macro in Excel to hide columns

Discussion in 'Business Applications' started by prephil, Jul 1, 2018.

Thread Status:
Not open for further replies.
  1. prephil

    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.
     

    Attached Files:

  2. Rollin_Again

    Rollin_Again

    Joined:
    Sep 4, 2003
    Messages:
    4,912
    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
     
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 733,556 other people just like you!

Loading...
Thread Status:
Not open for further replies.

Short URL to this thread: https://techguy.org/1212275

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice