+ Reply to Thread
Results 1 to 16 of 16

Created this toggel button, but it's not working. Please help!

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

    Created this toggel button, but it's not working. Please help!

    I wanted to create the following toggle button.
    Button would say 'Hide Done' and when clicked, it would hide all rows with the letter 'a' in cell in column B.
    Same button would now say 'Show Done', and when clicked again, it would show the rows again.

    Here's the code I came up with, but it's not working.

    Please Login or Register  to view this content.
    What am I doing wrong or missing?
    This has been driving me crazy for the past couple weeks, and have looked everywhere for an answer.

    Thanks.

  2. #2
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229

    Re: Created this toggel button, but it's not working. Please help!

    Cross Post
    http://www.mrexcel.com/forum/excel-q...ease-help.html
    _
    ...How to Cross-post politely...
    ..Wrap code by selecting the code and clicking the # or read this. Thank you.

  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: Created this toggel button, but it's not working. Please help!

    Please Login or Register  to view this content.
    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
    Forum Contributor
    Join Date
    09-26-2014
    Location
    Moscow, Russia
    MS-Off Ver
    MSE 10, MSE 13
    Posts
    179

    Re: Created this toggel button, but it's not working. Please help!

    Hello, Phoenix!

    What as for syntax, you need to close all "For Each cell" sentences with "Next cell" expressions.

    For basic Idea, you need to somehow differ - when button click will do "Hide" moves and when "Show" moves. For example, you may place somewhere a special cell with 1 or 0 value and do things according to it. You may differ cases with "Select Case" statement.

    And just to consider, several tips from "best practices":

    1). If you do "ActiveSheet.Unprotect" action - may be your code needs to invert it with "ActiveSheet.Protect" in the end.
    2). Range("$B:$B") is not the most optimal link for "For Each" cycle. I recommend to limit observing area. For example, you may declare another Integer variable (Let it be X) to find the last possible row of your data and then use range like this: Range("B1:B" & X)
    3). Using Application.ScreenUpdating = False is very tricky. It could be better to off updating before all invisible actions and get it back after with Application.ScreenUpdating = True
    Best wishes and have a nice day!

  5. #5
    Forum Contributor amartinez988's Avatar
    Join Date
    05-04-2015
    Location
    Miami
    MS-Off Ver
    Office 2010
    Posts
    183

    Re: Created this toggel button, but it's not working. Please help!

    I see some other experts helped you already, anyway I had this for you in order to help you out:

    Please Login or Register  to view this content.
    Hope that help you!

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

    Re: Created this toggel button, but it's not working. Please help!

    Thank you.
    I tried assigning the code above to Active X button, but it does not work.
    What am I missing?
    I tried both amartinez and Arkadi's to no avail.
    Thank you so much for all the responses, I greatly appreciate it.
    Last edited by The Phoenix; 07-13-2015 at 12:04 PM.

  7. #7
    Forum Contributor amartinez988's Avatar
    Join Date
    05-04-2015
    Location
    Miami
    MS-Off Ver
    Office 2010
    Posts
    183

    Re: Created this toggel button, but it's not working. Please help!

    Could you upload a copy of the workbook?

  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: Created this toggel button, but it's not working. Please help!

    Didn't realize it was activex:

    Please Login or Register  to view this content.

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

    Re: Created this toggel button, but it's not working. Please help!

    toggletest.xlsm
    OK, here it is with code above attached.
    It doesn't have to be an ActiveX button. I could be a regular button, but as you can see, text doesn't show up on button and it doesn't hide or unhide done rows when clicked.

    I know I must be doing something wrong. Have to admit, I cannot wait to see what it is.

    Again, thank you soooo much for all your help. I will make sure to keep adding to your reputation.

    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: Created this toggel button, but it's not working. Please help!

    Phoenix, my last post should work with activeX button... it doesn't do anything right now because the caption is CommandButton1 and my code works with caption 1 or 2, to figure out if it should hide or show.... so since no rows are hidden, start by giving the button the caption "Show Done" and then try again, it ought to work.

  11. #11
    Forum Contributor amartinez988's Avatar
    Join Date
    05-04-2015
    Location
    Miami
    MS-Off Ver
    Office 2010
    Posts
    183

    Re: Created this toggel button, but it's not working. Please help!

    If you start writing.. let's say in cell BA1 "FALSE" and you you use this code:
    Please Login or Register  to view this content.
    Should work to match your code.

  12. #12
    Forum Contributor amartinez988's Avatar
    Join Date
    05-04-2015
    Location
    Miami
    MS-Off Ver
    Office 2010
    Posts
    183

    Re: Created this toggel button, but it's not working. Please help!

    However, the solution that Arkadi is giving you is way more organized and structured. You should go with that one!

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

    Re: Created this toggel button, but it's not working. Please help!

    Hello Arkadi,

    Thanks for the response. Excuse my ignorance as I am relatively new at this, but how do I give a button a caption "Show Done"? Where would I type that?

    Thanks.

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

    Re: Created this toggel button, but it's not working. Please help!

    if you right click the activeX button, click on properties, you get a list... 7th item or so is Caption... change CommandButton1 to Show Done

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

    Re: Created this toggel button, but it's not working. Please help!

    GENIUS!!!! IT WORKS!!! UNBELIEVABLE!
    This has been driving me CRAZY!

    THANK YOU SO MUCH! YOU ROCK!!!!

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

    Re: Created this toggel button, but it's not working. Please help!

    Happy to help

+ 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. Creating a Button with VBA that can delete itself + the Row it's created on
    By ALoelke in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-15-2015, 08:37 PM
  2. [SOLVED] Created add-in - how to get it on ribbon with button
    By D_N_L in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 01-02-2014, 12:29 PM
  3. VBA & Macros created in 32-bit not working in 64-bit
    By JetKaren in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 12-02-2013, 10:15 PM
  4. Use toggel button to switch the content of an array of cells
    By deepakya3 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 10-08-2011, 07:52 AM
  5. Click events on buttons created at runtime only work on the last button created
    By Treacle in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-25-2010, 05:44 AM
  6. Code created in a Macro not working for a Command Button
    By Amber_D_Laws in forum Excel Programming / VBA / Macros
    Replies: 15
    Last Post: 01-13-2006, 06:40 PM
  7. [SOLVED] Button not bring up Macro I created
    By A.S. in forum Excel General
    Replies: 1
    Last Post: 07-22-2005, 06:05 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