+ Reply to Thread
Results 1 to 13 of 13

New Question to Hide Rows with Toggle button and auto adjust for additional rows

  1. #1
    Registered User
    Join Date
    01-02-2014
    Location
    Tampa, FL
    MS-Off Ver
    Excel 2010
    Posts
    22

    New Question to Hide Rows with Toggle button and auto adjust for additional rows

    OK, new question. As you will see from spreadsheet I uploaded, I have a 'Notes' Row, and wanted to add a toggle button to view or hide notes under each section.
    It works fine except when I add a row above it (an additional task). Obviously my code still toggles the row I designated but does not take into considaration and added or deleted rows above it.
    How can I make the code adjust automatically?

    Here's the Spreadsheet:
    toggletest.xlsm

    Here's the code I used:
    Please Login or Register  to view this content.
    Again, thank you. This forum has been a lifesaver thus far.

  2. #2
    Forum Expert skywriter's Avatar
    Join Date
    06-09-2014
    Location
    USA
    MS-Off Ver
    2016
    Posts
    2,760

    Re: New Question to Hide Rows with Toggle button and auto adjust for additional rows

    This code will get your the row number of your toggle button even after you add rows above it.
    You can probably handle it from there.
    Good Luck.

    Please Login or Register  to view this content.
    Click the * Add Reputation button in the lower left hand corner of this post to say thanks.

    Don't forget to mark this thread SOLVED by going to the "Thread Tools" drop down list above your first post and choosing solved.

  3. #3
    Forum Expert Arkadi's Avatar
    Join Date
    02-13-2014
    Location
    Smiths Falls, Ontario, Canada
    MS-Off Ver
    Office 365
    Posts
    5,059

    Re: New Question to Hide Rows with Toggle button and auto adjust for additional rows

    How about naming the range? for example click on B13, and where it shows B13 at the top/left, type in a name.... say "Project1Notes" then

    Please Login or Register  to view this content.
    becomes
    Please Login or Register  to view this content.
    EDIT: I see you have it named already, so you can change my name to just Notes and it should work... when you insert more, the named range moves, so it should always work
    Please help by:

    Marking threads as closed once your issue is resolved. How? The Thread Tools at the top
    Any reputation (*) points appreciated. Not just by me, but by all those helping, so if you found someone's input useful, please take a second to click the * at the bottom left to let them know

    There are 10 kinds of people in this world... those who understand binary, and those who don't.

  4. #4
    Registered User
    Join Date
    01-02-2014
    Location
    Tampa, FL
    MS-Off Ver
    Excel 2010
    Posts
    22

    Re: New Question to Hide Rows with Toggle button and auto adjust for additional rows

    Arkadi to save the day again. Worked like a charm. You're the MAN! (or woman, not sure by the name and don't want to offend )
    Again, Thank you so much.
    Skywriter, thank you as well. I've added to both your reputations.

    I appreciate it greatly!!!

  5. #5
    Forum Expert Arkadi's Avatar
    Join Date
    02-13-2014
    Location
    Smiths Falls, Ontario, Canada
    MS-Off Ver
    Office 365
    Posts
    5,059

    Re: New Question to Hide Rows with Toggle button and auto adjust for additional rows

    Phoenix, You are welcome, glad we could help you solve the problem
    (and yes Man)
    p.s. Thanks for the rep!

  6. #6
    Registered User
    Join Date
    01-02-2014
    Location
    Tampa, FL
    MS-Off Ver
    Excel 2010
    Posts
    22

    Re: New Question to Hide Rows with Toggle button and auto adjust for additional rows

    PM Task Tracking Template.xlsm
    OK, spoke too soon. Not sure what happened. It seemed to be working, but now, when I click on button, it says
    Run-time error '1004'
    Method 'Range' of Object'_Worksheet' failed.
    I've attached spreadsheet. Can't figure out what's wrong.

    Thanks.

  7. #7
    Forum Expert skywriter's Avatar
    Join Date
    06-09-2014
    Location
    USA
    MS-Off Ver
    2016
    Posts
    2,760

    Re: New Question to Hide Rows with Toggle button and auto adjust for additional rows

    The line you are getting the error on is, at the time of the error, referring to the Documents List sheet and it's trying to hide the range named Notes1, which according to your name manger, is on a different sheet.
    Last edited by skywriter; 07-14-2015 at 09:48 AM.

  8. #8
    Forum Expert Arkadi's Avatar
    Join Date
    02-13-2014
    Location
    Smiths Falls, Ontario, Canada
    MS-Off Ver
    Office 365
    Posts
    5,059

    Re: New Question to Hide Rows with Toggle button and auto adjust for additional rows

    Phoenix... the problem is that you are making the code do the range("Notes").entirerow.hidden = true run for each ws in the workbook. The range only exists on one sheet.

    Why for each ws in workbook? The ranges only exist on that one sheet...

  9. #9
    Registered User
    Join Date
    01-02-2014
    Location
    Tampa, FL
    MS-Off Ver
    Excel 2010
    Posts
    22

    Re: New Question to Hide Rows with Toggle button and auto adjust for additional rows

    PM Task Tracking Template.xlsmSo how do I fix that?
    I think I fixed the names in Name Manager, but how do I set it to only this worksheet?

    Thanks.

  10. #10
    Forum Expert Arkadi's Avatar
    Join Date
    02-13-2014
    Location
    Smiths Falls, Ontario, Canada
    MS-Off Ver
    Office 365
    Posts
    5,059

    Re: New Question to Hide Rows with Toggle button and auto adjust for additional rows

    remove for each ws loop, it is all over your code, why? Using ToggleButton2_Click() as example, code should just look like this I think:

    Please Login or Register  to view this content.
    Last edited by Arkadi; 07-14-2015 at 12:12 PM.

  11. #11
    Registered User
    Join Date
    01-02-2014
    Location
    Tampa, FL
    MS-Off Ver
    Excel 2010
    Posts
    22

    Re: New Question to Hide Rows with Toggle button and auto adjust for additional rows

    Perfect. Again, you ROCK! Worked perfect! Thank you!!!!

  12. #12
    Forum Expert Arkadi's Avatar
    Join Date
    02-13-2014
    Location
    Smiths Falls, Ontario, Canada
    MS-Off Ver
    Office 365
    Posts
    5,059

    Re: New Question to Hide Rows with Toggle button and auto adjust for additional rows

    You have some cleaning up to do on the others, but it should be pretty easy now that you have a working example. Glad we could help out again

  13. #13
    Valued Forum Contributor
    Join Date
    10-05-2014
    Location
    Regina, SK Canada
    MS-Off Ver
    Excel for Mac 11
    Posts
    330

    Re: New Question to Hide Rows with Toggle button and auto adjust for additional rows

    Hi - Just a thought here of another approach for showing & hiding notes on a sheet.

    1. Create a text box and name it 'Notes.
    2. Set its properties to 'Don't move or resize with cells'.
    3. Use this macro to toggle it visible or not.
    4. Assign the macro to a command button on the sheet(s).

    Please Login or Register  to view this content.
    Advantages:
    a) It will not be affected when rows/columns are added or removed.
    b) Each sheet can have its own 'Notes' text box; the macro will work with them all.

    Note:
    When you initially create the textboxes using the 'Insert' menu, they are automatically named 'Textbox 1', 'Textbox 2' etc.
    The following utility subroutine can be used to rename each one to just 'Notes' (or whatever you want).
    Tip: Make the first text box and rename. Then just copy it and paste onto other sheets.

    Please Login or Register  to view this content.
    A sample program is attached to show this concept - notes are on 2 sheets with 1 macro to show/hide each.
    Attachment 407183

    Food for thought - my 2¢ worth.
    - Stu
    Last edited by StuCram; 07-14-2015 at 02:08 PM. Reason: Add [CODE] {/CODE] & Attachment

+ 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. Need Toggle Button to hide/unhide rows based on cell value in non concurrent rows
    By The Phoenix in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 07-13-2015, 10:49 AM
  2. Show/Hide Rows & Columns Toggle Button
    By axegrynder in forum Excel General
    Replies: 2
    Last Post: 06-29-2015, 06:38 PM
  3. [SOLVED] Toggle Button to hide/unhide rows based on value
    By goomblar in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 10-03-2014, 07:35 AM
  4. Auto Hide/Unhide rows in Excel based on radio button selection
    By awill110 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-30-2013, 03:05 PM
  5. Toggle Tab to Hide Columns and Rows with NO Data
    By Battledeck in forum Excel General
    Replies: 0
    Last Post: 06-18-2012, 06:01 PM
  6. [SOLVED] Toggle button to hide rows if empty and has no color
    By hi2chris in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 04-10-2012, 08:56 PM
  7. Using Toggle Button to hide/unhide rows that may change
    By jmpatrick in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-09-2011, 09:48 AM

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