+ Reply to Thread
Results 1 to 8 of 8

Unhide hidden rows with active button

  1. #1
    Registered User
    Join Date
    10-20-2019
    Location
    Bulgaria
    MS-Off Ver
    Microsoft office 365 pro plus
    Posts
    13

    Unhide hidden rows with active button

    Hi guys,

    I want to create an active button in excel that will hide/unhide rows when clicked.
    The thing is that I will have rows 13-17 hidden. I want on one click of the button to unhide row 13, the second click should unhide row 13 and 14, the next will unhide row 13, 13 and 15 and so on - until row 17. I will create a separate button that upon being clicked will hide rows 13-17. ()

    Making the button insert rows is not an option, because I have another button like that further down the sheet and if I add rows above it it messes up the code. The button that is down adds rows between row 33 and 34 and if I add a row between 13 and 14 that will make rows 33 and 34 rows 34 and 35. If you know a way to make the code of the second macro react to rows being added above it that would also work.

    Do you think something like that is possible?

    Thank you in advance!

    Best,
    Alexander
    Last edited by amilchev; 10-25-2019 at 11:03 AM.

  2. #2
    Forum Expert WideBoyDixon's Avatar
    Join Date
    10-03-2016
    Location
    Sheffield, UK
    MS-Off Ver
    365
    Posts
    2,182

    Re: Unhide hidden rows with active button

    Button code would look something like this:

    Please Login or Register  to view this content.
    WBD
    Office 365 on Windows 11, looking for rep!

  3. #3
    Forum Expert Greg M's Avatar
    Join Date
    08-16-2007
    Location
    Dublin. Ireland
    MS-Off Ver
    Office 2016
    Posts
    4,481

    Re: Unhide hidden rows with active button

    Hi there,

    Define Rows 13-17 of your worksheet as a Named Range called "ptrRowsToHide", and then see if the following code does what you need:

    Please Login or Register  to view this content.
    The highlighted values may be altered to suit your requirements.


    Regarding:


    If you know a way to make the code of the second macro react to rows being added above it . . .
    the most straightforward way to approach this is to define the rows "further down" the worksheet as a Named Range, and to have your VBA code reference rows in the Named Range rather than specifically numbered rows on the worksheet.


    Hope this helps - please let me know how you get on.

    Regards,

    Greg M

  4. #4
    Registered User
    Join Date
    10-20-2019
    Location
    Bulgaria
    MS-Off Ver
    Microsoft office 365 pro plus
    Posts
    13

    Re: Unhide hidden rows with active button

    Hi all,

    Thank you for your answers. The command button works for un-hiding rows 13 to 17 by clucking it. I was trying to make it do the same for columns D to H, however, for some reason it does not work. Please find the code below. Would appreciate any help.

    Please Login or Register  to view this content.

    Thank you!

  5. #5
    Registered User
    Join Date
    10-20-2019
    Location
    Bulgaria
    MS-Off Ver
    Microsoft office 365 pro plus
    Posts
    13

    Re: Unhide hidden rows with active button

    Hi guys,

    I managed to get it to work - the issue was that the columns had to be defined not as D to H, but rather as 4 to 8.

    Now the last problem I have is that I have created another button that is supposed to hide rows 13 to 17 and columns D to H when clicked, however, I cannot seem to get it to work. Any suggestions? It should only hide the rows - not make them appear.

    Thank you!

    Best,
    Alex

  6. #6
    Forum Expert WideBoyDixon's Avatar
    Join Date
    10-03-2016
    Location
    Sheffield, UK
    MS-Off Ver
    365
    Posts
    2,182

    Re: Unhide hidden rows with active button

    Please Login or Register  to view this content.
    WBD

  7. #7
    Registered User
    Join Date
    10-20-2019
    Location
    Bulgaria
    MS-Off Ver
    Microsoft office 365 pro plus
    Posts
    13

    Re: Unhide hidden rows with active button

    Hi,

    Everything works now! Thanks all for the help!

    Please Login or Register  to view this content.
    Best,
    Alex

  8. #8
    Forum Expert Greg M's Avatar
    Join Date
    08-16-2007
    Location
    Dublin. Ireland
    MS-Off Ver
    Office 2016
    Posts
    4,481

    Re: Unhide hidden rows with active button

    Hi again,

    Many thanks for your feedback,

    You're welcome - glad I was able to help.

    Regards,

    Greg M

+ 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. Macro button hide/unhide all sheets except active
    By cargo79 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 08-28-2019, 07:51 AM
  2. [SOLVED] VBA to unhide hidden rows
    By Sam Capricci in forum Excel Programming / VBA / Macros
    Replies: 14
    Last Post: 08-14-2018, 09:09 AM
  3. Unhide Hidden Sheet when search button is used
    By cjames2012 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-18-2014, 11:04 PM
  4. [SOLVED] hidden rows wont unhide.
    By FDibbins in forum Excel General
    Replies: 8
    Last Post: 08-15-2014, 04:31 PM
  5. How to unhide rows that are not hidden
    By amartino44 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 02-25-2013, 08:09 PM
  6. Hidden Rows with VBA - Cannot Unhide
    By prairied0gg in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 04-30-2010, 01:17 AM
  7. Unhide Hidden Rows
    By bruce2444 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 09-08-2009, 09:53 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