+ Reply to Thread
Results 1 to 5 of 5

VBA Code for Option Buttons to return YES or NO instead of TRUE or FALSE

  1. #1
    Registered User
    Join Date
    07-29-2013
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    11

    VBA Code for Option Buttons to return YES or NO instead of TRUE or FALSE

    Hello ladies and gentlemen,

    I need some help; I have an Excel spread sheet that I use for data collection for my job. I commission solar inverters. Each row contains information for the station that I am commissioning. I collect this data with a UserForm that I created and this with a button on the UserForm it will fill out the PDF Commissioning Report with the data from that row. Right now I am using list boxes for yes and no because Adobe Acrobat requires “Yes” or “No” for Checkboxes not “True” or “False”. I would like to be able to use OptionButtons.

    Example: There are 3 Station Types, so I would like to have 3 OptionButtons in a group StationType. The options would be named “zAC”, “zAD” and “zAE” (they have to be named that way due to other code in my form) and they would return values “Yes” or “No” to their respective cells AC, AD and AE for the row that I am currently entering data on.

    I’ve searched the internet and tried multiple codes but I can’t get any of them to work, either it still returns “True” or “False” to the cells or I get an error. It’s probably me; I’m not the best with Visual Basics. Any help with a code that would work would be much appreciated.
    Last edited by mebanet; 07-31-2013 at 02:43 AM.

  2. #2
    Forum Expert
    Join Date
    04-22-2013
    Location
    .
    MS-Off Ver
    .
    Posts
    4,418

    Re: VBA Code for Option Buttons to return YES or NO instead of TRUE or FALSE

    Can you just use something like:
    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    07-29-2013
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    11

    Re: VBA Code for Option Buttons to return YES or NO instead of TRUE or FALSE

    Up Load.zip

    It's still not working. I'm uploading my file. In the folder there are two Excel files, one with Toggle Buttons and one with Option Buttons. I put the Toggle Buttons on one because I think the code for them will be easier but I would prefer Option Buttons; however I can’t get either to work so I’ll take what I can get.
    Option Buttons:
    1. There are 3 Option Buttons named zI, zJ and zK captioned “SMA CoMVPP” “SMA MVPP” and “CUSTOMER SUPPLIED” respectively.
    2. Option Button zI will enter data in to Cell I for the current row I am entering data in, zJ will enter into J and zK will enter into K.
    3. Right now if I check zI, “True” will be entered into Cell I and “False” will be entered into Cells J and K.
    4. If you look at my UserForm you will notice that there is a Command Button labeled “Generate Report” if you click it, it will transfer the data from the selected row in the Excel spread sheet to a PDF which I have also included in the upload.
    5. Unfortunately Adobe Acrobat requires “Yes” and “No” for checkboxes not “True” and “False” so everything will be filled out accept the checkboxes on the PDF.
    6. So I need the Option Buttons to return “Yes” and “No” to their respective cells instead of “True” and “False”
    Toggle Buttons:
    1. The Toggle Buttons will do the same as the Option Buttons except I can click all of them at the same time.
    Yudlugar’s code probally works, I’m probably just not entering it right.

  4. #4
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: VBA Code for Option Buttons to return YES or NO instead of TRUE or FALSE

    Hi mebanet

    Welcome to the Forum!

    Try this Code for your Save Button
    Please Login or Register  to view this content.
    John

    If you have issues with Code I've provided, I appreciate your feedback.

    In the event Code provided resolves your issue, please mark your Thread as SOLVED.

    If you're satisfied by any members response to your issue please use the star icon at the lower left of their post.

  5. #5
    Registered User
    Join Date
    07-29-2013
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    11

    Cool Re: VBA Code for Option Buttons to return YES or NO instead of TRUE or FALSE

    Yes, that code worked thank you. The only problem is that the "Get Data" sub wasn't working correctly. When I open the UserForm on a row that has data it is populated with that data. All my Text Boxes were working fine but my Toggle Buttons were grayed out. They were looking for a True or False to tell them what state they should be in. I had to add a bit of code to the "Get Data" sub to fix this problem.

    New "Get Data" Code

    Please Login or Register  to view this content.
    Old "Get Data" Code

    Please Login or Register  to view this content.

+ 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. Option buttons return true/false rather than 1/2
    By ABSTRAKTUS in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 08-03-2011, 05:59 PM
  2. [SOLVED] Search for 2 true arguments and return true or false
    By David in forum Excel General
    Replies: 3
    Last Post: 07-15-2006, 05:20 AM
  3. Check box - true/false - i'd like a third option n/a
    By Kelly 1st in forum Excel General
    Replies: 4
    Last Post: 06-02-2006, 08:15 AM
  4. [SOLVED] Function to return True/False if all are validated as True by ISNU
    By Tetsuya Oguma in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 03-15-2006, 06:30 AM
  5. IF Statement: How do you have a true and false for each option?
    By timmadge in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 02-07-2006, 01:45 PM

Tags for this Thread

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