+ Reply to Thread
Results 1 to 6 of 6

Macro for hiding pre-defined columns

  1. #1
    Forum Contributor
    Join Date
    12-02-2008
    Location
    India
    Posts
    118

    Macro for hiding pre-defined columns

    Hey all,
    I'm updating my workbook to add some more features that would make my workbook more userfriendly.
    I'm trying to find a macro that would hide specific combination of columns based on what I want to do when i open this workbook so that i could avoid wasting time to keep tabbing and finish punching the data in lesser time.

    To do this i'm planning to make a switchboard page in my first sheet with a list and give them radio buttons:
    Full View Unhide all Columns
    New Trip Entry Hide columns C,D,E,J,K,L,M,N,Z-AL,AN-AU
    Acknowledgement Entry Hide columns E,M,N,S,T,U,V,W,X,Y,Z,AA,AF-AU
    Bill Entry ....
    Receipt Entry ....
    Balance Payment Entry ....
    Delay Report ....
    Vehicle Running Report ....

    I tried recording a macro to do the above but it is unbelievably long and ineffective as it hides all the columns from A to AU. Somehow, I did manage to find something

    Please Login or Register  to view this content.
    But the Above code works on the same worksheet as the button is in... and I want it to work on "Datasheet" worksheet

    I know I have to add activate sheet code but i dont know the language.
    Edit: I just realised there is one more thing that needs to be done before actually hiding columns and that is to unhide all columns.

    Please Help.

    Thanks And Regards

    Mohit
    Last edited by mohitspamz; 08-05-2010 at 05:47 AM.

  2. #2
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Macro for hiding pre-defined columns

    It might be better to attach an example workbook.

    This example will work on Sheet3

    Please Login or Register  to view this content.
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  3. #3
    Forum Contributor
    Join Date
    12-02-2008
    Location
    India
    Posts
    118

    Re: Macro for hiding pre-defined columns

    Thanks!
    That was easy as a pie.

    I had managed to try the code on my workbook and succeeded day before yesterday evening. But yesterday morning when i tried opening the workbook again i got "file corrupted" error and excel couldnt even recover the file back.
    So i decided to redo the whole workbook again (it was really a pain to look at my whole day's work go down the drain cuz excel 2003 got unstable.

    Since the website was down the whole day yesterday and i didnt have any reference to the code, i tried writing it again but instead of range I used columns.

    But i kept getting some syntax error.
    I tried to keep the code

    Please Login or Register  to view this content.
    and

    Please Login or Register  to view this content.
    But both didnt work.

    Although since the forum is up and running and i can refer back to it now i'm back to Range and it works I'd still like to know why Column didnt work.

    PS: Can the corrupted file be recovered back? I'm not sure if i can attach it here because it got more than 6 mb in size i think.. Although i could upload it to rapidshare and share the link if thats ok.

    Thanks and regards
    Mohit
    Last edited by mohitspamz; 08-07-2010 at 02:41 AM. Reason: Code tag

  4. #4
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Macro for hiding pre-defined columns

    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code. Posting code without them makes your code hard to read and difficult to be copied for testing. Highlight your code and click the # at the top of your post window. For more information about these and other tags, found here

  5. #5
    Forum Contributor
    Join Date
    12-02-2008
    Location
    India
    Posts
    118

    Re: Macro for hiding pre-defined columns

    Edited.

    Apologies for the inconvenience.

  6. #6
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Macro for hiding pre-defined columns

    Thank you.

    You refer to columns by their numbers

    Please Login or Register  to view this content.
    or
    Please Login or Register  to view this content.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1