Results 1 to 6 of 6
  1. #1
    New Lounger
    Join Date
    May 2007
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Syntax for If statement and Checkboxes (2003)

    I'd like to create an IF statement on multiple check boxes that returns the text associated with the box that is checked. Or, alternatively, an option that would require more effort would be to have it return text that is included in the IFstatement (as I'm attempting below). The checkboxes will be in a different workbook named "Test.xls" and a different worksheet (named "Book1") than the IF statement.
    Maybe something like this??

    =IF("'[Test.xls]'Book1!CheckBox1"=TRUE,"Example 1",IF("'[Test.xls]'Book1!CheckBox2"=TRUE,"Example 2"), "none checked")

    Where "Text.xls" is the name of the workbook
    "Book1" is the name of the worksheet
    Checkbox 1 has the text "Example 1"
    Checkbox 2 has the text "Example 2"

    Thanks for your help in advance.

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Syntax for If statement and Checkboxes (2003)

    Welcome to Woody's Lounge!

    There is no direct way to refer to a check box in a formula, but fortunately, you don't need to. You can (and should) set a linked cell for each check box. The cell will contain TRUE if the check box is ticked, and FALSE if the check box is cleared.
    Let's say that you link the first check box to cell A1 and the second check box to cell A2 (both on the Book1 worksheet in the Test.xls workbook).
    The formula you want becomes
    <code>
    =IF([Test.xls]Book1!$A$1,"Example 1",IF([Test.xls]Book1!$A$2,"Example 2","None checked"))
    </code>
    Note: since the cells return TRUE or FALSE, we don't need to compare to TRUE, we can use the cell value itself as condition.

  3. #3
    New Lounger
    Join Date
    May 2007
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Syntax for If statement and Checkboxes (2003)

    Hans,
    Thanks for your quick reply. I didn't mention that I'll need to do this for hundreds of checkboxes in 50 workbooks.. so, it looks like I'll need to go through each of the 50 workbooks and assign the check boxes to individual cells. Is that correct? If so, is there a quick way to do this since all of my workbooks are set up similarly? One option might be to create a new worksheet that I could insert into each of the 50 workbooks.. I'll try.
    Thanks for any suggestions.

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Syntax for If statement and Checkboxes (2003)

    If the sheet looks exactly the same in each workbook, preparing a single sheet, then inserting it in the workbooks seems like a good idea.
    It would probably also be possible to write VBA code to assign the linked cells, but the exact code needed depends on the structure of the workbook.

  5. #5
    New Lounger
    Join Date
    May 2007
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Syntax for If statement and Checkboxes (2003)

    Hans,
    I appreciate the help.. Looks like I'll need to go to VBA given that none of the boxes are linked to cells. Thanks again.
    BAJ

  6. #6
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Syntax for If statement and Checkboxes (2003)

    If you need help with the VBA, post back with more detailed information.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •