+ Reply to Thread
Results 1 to 8 of 8

Hide/unhide rows in excel using macro

  1. #1
    Forum Contributor
    Join Date
    09-11-2012
    Location
    minot, north dakota
    MS-Off Ver
    Excel 2010
    Posts
    127

    Hide/unhide rows in excel using macro

    I need help creating a macro that will hide and unhide rows when the macro button is clicked. I need to hide rows 11 through 28 if column "I" is blank. I would like to add the macro button to be able to hide the rows that do not have a value in column "I" but if rows need to be adjusted click the macro button to show all rows. If it is possible to make the macro to work for all sheets between the tabs labeled First and Last that would be a great bonus. Any help would be greatly appreciated.

  2. #2
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,788

    Re: Hide/unhide rows in excel using macro

    Try the below code…

    Please Login or Register  to view this content.


    If your problem is solved, then please mark the thread as SOLVED>>Above your first post>>Thread Tools>>
    Mark your thread as Solved


    If the suggestion helps you, then Click *below to Add Reputation

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

    Re: Hide/unhide rows in excel using macro

    A for each approach with external calls via ActiveX Toggle Button.

    1. Copy and paste the following (all of it) into a standard module.
    Please Login or Register  to view this content.
    2. Create your button by drawing an ActiveX toggle button (Developer Tab > Controls Group > "Insert" > ToggleButton) onto the worksheet in your preferred location.

    3. Right-click the toggle button > View Code.

    4. Copy and Paste the following between the auto-created (by Excel) "Private Sub" and "End Sub":
    Please Login or Register  to view this content.
    5. Deactivate "Design Mode" (also on the Developer Tab in the Controls Group)
    Last edited by AlvaroSiza; 10-22-2013 at 01:45 AM.
    Perhaps it was the Noid who should have avoided me...
    If you are satisfied with my solution click the small star icon on the left. Thanks
    1. Make a copy of your workbook and run the following code on your copy (just in case)
    2. With excel open, press ALT+F11 to open the Visual Basic Editor (VBE). From the "Insert" menu, select "Module".
    3. Paste the code from above into the empty white space. Close the VBE.
    4. From the developer tab, choose "Macros", select the Sub Name, and click "Run".

  4. #4
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 365 on Win11 (desktop), 2019 on Win11 (notebook)
    Posts
    8,198

    Re: Hide/unhide rows in excel using macro

    Hi, aaron061883,

    based on the first code maybe
    Please Login or Register  to view this content.
    Ciao,
    Holger
    Use Code-Tags for showing your code: [code] Your Code here [/code]
    Please mark your question Solved if there has been offered a solution that works fine for you

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

    Re: Hide/unhide rows in excel using macro

    Holger,

    Would your code still hold in a situation where the "First" and "Last" sheets are not actually the left-most and right-most worksheets in the workbook?

    #learning

  6. #6
    Forum Contributor
    Join Date
    09-11-2012
    Location
    minot, north dakota
    MS-Off Ver
    Excel 2010
    Posts
    127

    Re: Hide/unhide rows in excel using macro

    Yes that is the case as the first tab is actually the 6 tab in the workbook

  7. #7
    Forum Contributor
    Join Date
    09-11-2012
    Location
    minot, north dakota
    MS-Off Ver
    Excel 2010
    Posts
    127

    Re: Hide/unhide rows in excel using macro

    Solved I am not sure how to add the solved feature to the post

  8. #8
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 365 on Win11 (desktop), 2019 on Win11 (notebook)
    Posts
    8,198

    Re: Hide/unhide rows in excel using macro

    Hi, AlvaroSiza,

    not a big thing to alter in the code:
    Please Login or Register  to view this content.
    @aaron061883:
    Quote Originally Posted by FAQ
    To mark your thread solved do the following:
    New Method
    -Go to the top of the first post
    -Select Thread Tools
    -Select Mark thread as Solved

    Old Method
    - Go to the first post
    - Click edit
    - Click Advance
    - Just below the word "Title:" you will see a dropdown with the word No prefix.
    - Change to Solve
    - Click Save
    Ciao,
    Holger

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Hide/Unhide Rows macro
    By nvalencia in forum Excel Programming / VBA / Macros
    Replies: 14
    Last Post: 10-08-2012, 01:44 PM
  2. Hide/Unhide rows using a macro
    By Jazzy Max in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 09-10-2012, 07:03 AM
  3. Hide/Unhide Rows Macro
    By wpwalsh in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-07-2011, 08:42 AM
  4. Macro to hide/unhide rows using box
    By jgomez in forum Excel General
    Replies: 10
    Last Post: 03-05-2011, 03:41 AM
  5. Macro to Hide/Unhide Rows
    By pgwolfe in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 06-24-2008, 09:02 PM

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