+ Reply to Thread
Results 1 to 10 of 10

a macro on a button to switch between the text FALSE and TRUE on a separate sheet

  1. #1
    Registered User
    Join Date
    07-15-2015
    Location
    Leeds, England
    MS-Off Ver
    2010
    Posts
    3

    a macro on a button to switch between the text FALSE and TRUE on a separate sheet

    Sorry if this has been asked before but I have searched to the best of my ability in the forums and not found the answer I need.

    What I need is for a macro that will be attached to a button that switches the text in a cell from a separate worksheet (same workbook) from the text "TRUE" to "FALSE".

    e.g. Text in sheet2, B11 currently reads "FALSE" > Clicks button on sheet1 > text in sheet2, B11 now reads "TRUE" > Clicks button on sheet1 again > text in sheet2, B11 now reads "FALSE"

    I haven't really learnt programming that much but I do understand the basics.

    So far I've tried adapting the code from http://www.excelforum.com/excel-prog...le-on-off.html to fit my use but it only works for the first click (which in this case was turning B11 from "TRUE" or a blank cell to "FALSE") but did not change when clicked a second time.

    Here's the code I changed it to (which is probably completely wrong due to me not being savvy with programming):
    Please Login or Register  to view this content.
    Only the code from beneath the "'Action 1 e.g.:" comment to the "Sheets(Item Selector").Select" worked. I need it to turn the text back to "TRUE" after clicking a second time then back to "FALSE" on a third click, etc.

    Please help. I would appreciate an answer ASAP, please. I don't mind if a completely new code is needed, I just want the button to work how I want it to.

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

    Re: a macro on a button to switch between the text FALSE and TRUE on a separate sheet

    Let me know how this looks. Don't worry if it's not exact we can customize it to your needs.
    Attached Files Attached Files
    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 gmr4evr1's Avatar
    Join Date
    11-24-2014
    Location
    Texas
    MS-Off Ver
    Office 2010 and 2007
    Posts
    3,448

    Re: a macro on a button to switch between the text FALSE and TRUE on a separate sheet

    Check the attached. Click the button on sheet1 and it Changes sheet2 B11 to True or False depending on what is there.

    Alunara True - False Button.xlsm
    1N73LL1G3NC3 15 7H3 4B1L17Y 70 4D4P7 70 CH4NG3 - 573PH3N H4WK1NG
    You don't have to add Rep if I have helped you out (but it would be nice), but please mark the thread as SOLVED if your issue is resolved.

    Tom

  4. #4
    Forum Expert gmr4evr1's Avatar
    Join Date
    11-24-2014
    Location
    Texas
    MS-Off Ver
    Office 2010 and 2007
    Posts
    3,448

    Re: a macro on a button to switch between the text FALSE and TRUE on a separate sheet

    For some reason the link didn't work, try this one.
    Alunara True - False Button V2.xlsm
    If it doesn't open for you, save it to your pc then open it. Not sure why it's doing this.

    Or, use this code for your button
    Please Login or Register  to view this content.
    Last edited by gmr4evr1; 07-15-2015 at 07:33 PM. Reason: Added code

  5. #5
    Forum Expert
    Join Date
    02-22-2013
    Location
    London, UK
    MS-Off Ver
    Office 365
    Posts
    1,218

    Re: a macro on a button to switch between the text FALSE and TRUE on a separate sheet

    To toggle:
    Please Login or Register  to view this content.

  6. #6
    Forum Expert gmr4evr1's Avatar
    Join Date
    11-24-2014
    Location
    Texas
    MS-Off Ver
    Office 2010 and 2007
    Posts
    3,448

    Re: a macro on a button to switch between the text FALSE and TRUE on a separate sheet

    Thanks berlan for the much cleaner code there.

  7. #7
    Registered User
    Join Date
    07-15-2015
    Location
    Leeds, England
    MS-Off Ver
    2010
    Posts
    3

    Re: a macro on a button to switch between the text FALSE and TRUE on a separate sheet

    I've used the code given by gmr4evr1 because I understood it better. It worked and thank you so much :D. Thank you to the rest of you as well for giving me help as well so soon, I appreciate it a lot .

  8. #8
    Forum Expert
    Join Date
    02-22-2013
    Location
    London, UK
    MS-Off Ver
    Office 365
    Posts
    1,218

    Re: a macro on a button to switch between the text FALSE and TRUE on a separate sheet

    Thanks for the feedback. Fyi, the logic behind my code is that True = Not False (and likewise, False = Not True). So if B11 = True then Not True will be False.

  9. #9
    Forum Expert gmr4evr1's Avatar
    Join Date
    11-24-2014
    Location
    Texas
    MS-Off Ver
    Office 2010 and 2007
    Posts
    3,448

    Re: a macro on a button to switch between the text FALSE and TRUE on a separate sheet

    You're welcome, glad it worked for you.

  10. #10
    Registered User
    Join Date
    07-15-2015
    Location
    Leeds, England
    MS-Off Ver
    2010
    Posts
    3

    Re: a macro on a button to switch between the text FALSE and TRUE on a separate sheet

    Thanks for letting me know the logic behind your code berlan. Like I mentioned before when I posted the query, I'm not a programmer and only have a basic understanding of it so your explanation is very educational for me. Thanks again .

+ 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. userform toggle button, 3 selection options? True, False and caption.
    By nvandyken in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-27-2015, 02:08 PM
  2. What is best to use for helper cells 0 or 1, typed true or false or =true =false
    By Gingermuppet in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-20-2014, 10:41 PM
  3. [SOLVED] Use checkbox on sheet ('true' or 'false') to decide if run macro
    By maacmaac in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-01-2013, 09:12 PM
  4. [SOLVED] in this TRUE OR FALSE function, i want desired name instead of display true or false
    By vengatvj in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 10-15-2013, 06:44 PM
  5. [SOLVED] VBA - Button (Form Control) - Visible = True/False
    By mcmunoz in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-23-2013, 01:45 AM
  6. Command Button True/False States
    By HangMan in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 07-19-2011, 06:08 PM
  7. Replies: 7
    Last Post: 06-27-2007, 08:39 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