+ Reply to Thread
Results 1 to 5 of 5

Creating a Macro that hides part of your spreadsheet

  1. #1
    Registered User
    Join Date
    10-03-2007
    Posts
    20

    Creating a Macro that hides part of your spreadsheet

    What Im trying to do is create a Macro assigned to a button that would allow the person looking at it to only see a particular part:

    eg:

    This might be the existing:

    A B C D E F

    1 Title Name Number Attendance Result Total


    On pressing the button, the person would see the following:

    B D E

    1 Name Attendance Result


    Thanks!

    Rob

  2. #2
    Valued Forum Contributor AlvaroSiza's Avatar
    Join Date
    09-19-2007
    Location
    Staffordshire
    MS-Off Ver
    2007
    Posts
    591

    Hiding Columns

    Assuming you want one button to hide the data and another to show it (or you will have to manually highlight the columns and right-click -> unhide...

    To hide...

    Please Login or Register  to view this content.
    Insert a button from the control toolbox. Right-Click -> View Properties...rename the button ("caption") and format it how you want it. Now right-click the button and choose "View Code". Type HideColumns where the cursor is active. This will assign the above code to that button.

    To re-show the columns

    Please Login or Register  to view this content.
    Again...go through same steps as before as to creating the button and formating. After "View Code" the name will be ShowColumns.

    Use your macro recorder. Despite some unnecessary code, its a great way to learn. And I am sure that there is a one-line code to do what you wanted, but this will definately do the trick. See attached for code and reference. Hope this helps.
    Attached Files Attached Files

  3. #3
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    WinXP/MSO2007;Win10/MSO2016
    Posts
    12,663
    Try these:
    Please Login or Register  to view this content.
    Ben Van Johnson

  4. #4
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    Consider Custom Views from the View menu. You can automate switching views with VBA.
    Hope that helps.

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

    Free DataBaseForm example

  5. #5
    Registered User
    Join Date
    10-03-2007
    Posts
    20
    Thanks a lot guys,

    that worked a trick!

    Cheers,

    Rob

+ 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