Error Checking in Excel
Thanks Thanks:  0
Likes Likes:  0
Results 1 to 3 of 3

Thread: macro problem when i hide fields how to get around?

  1. #1
    New Member
    Join Date
    Mar 2002
    Posts
    26
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    Hi,
    I am trying to hide 2 columns when i hide it without macro it only selects the 2 columns which i selected but when i run it with macro it selects all the columns and hides everything.
    It must be doing it because i have merge fields at the top of the sheet. but why does it not do that outside of macro?

  2. #2
    MrExcel MVP Damon Ostrander's Avatar
    Join Date
    Feb 2002
    Location
    Denver, Colorado USA
    Posts
    4,239
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    Hi ap1,

    This is just one of many examples of recorded code that does not do the same thing as the manual operations that were recorded. Recording is a handy feature, but occasionally one must actually write the VBA code manually to get it to do what you want. Usually the result of writing the code manually is also much cleaner, more efficient code, as is the case in this instance. You should be able to change your code to (this example just for hiding column D):

    Columns(4).Hidden = True



    Keep Excelling.

    Damon

    VBAexpert Excel Consulting
    LinkedIn Profile http://www.linkedin.com/pub/damon-ostrander/7/79/a93
    AllExperts Profile http://www.allexperts.com/ep/1059-30...-Ostrander.htm

  3. #3
    New Member
    Join Date
    Mar 2002
    Posts
    26
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    Thanks. Appreciate your response.

Some videos you may like

User Tag List

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •