+ Reply to Thread
Results 1 to 7 of 7

Boolean racking my brain

Hybrid View

  1. #1
    Registered User
    Join Date
    11-11-2008
    Location
    Wilmington
    Posts
    26

    Boolean racking my brain

    Ok guys i need someone that can think through this boolean logically. its been a long day at work and now I'm trying to walk through this boolean thing to make sure my data will post on the right pages.

    I have an Excel Macro that will capture inputted customer/vehicle data from an input screen, at the end, based on questions answered, i need to place that data on 1 of 4 sheets in my excel document.

    The questions are:
    Is this a Nationwide claim? (Y.N) (boolean = nw)
    Is the vehicle here? (Y/N) (boolean = vh)

    So here's what i got
    if NW = true and VH = True then place data on "sheet1"
    if NW = true and VH = False then place data on "Sheet2"
    if NW = False and VH = true then place data on "sheet 3"
    if NW = false and VH = False then place data on "sheet4"

    I can't think of how to write this IF statement for this to happen. can't get the logic going.

    OR IS THERE A BETTER WAY?? i'm sure there is....

    Thanks to those who took time to read all this post
    Last edited by eighty2scrambler; 11-11-2008 at 07:09 PM. Reason: Thanks!

  2. #2
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689
    Welcome to the forum. Your way is fine, and there are several others possible. Here's one.

        Dim bNW As Boolean
        Dim bVH As Boolean
        
        ' other code
        If bNW Then
            If bVH Then
                Sheet1.Select
            Else
                Sheet2.Select
            End If
        Else
            If bVH Then
                Sheet3.Select
            Else
                Sheet4.Select
            End If
        End If
    Please take a few minutes to read the Forum Rules about thread titles before starting your next thread.
    Last edited by shg; 11-11-2008 at 06:59 PM.
    Entia non sunt multiplicanda sine necessitate

  3. #3
    Forum Expert Bob Phillips's Avatar
    Join Date
    09-03-2005
    Location
    Wessex
    MS-Off Ver
    Office 2003, 2010, 2013, 2016, 365
    Posts
    3,284
    Select Case True
        Case NW And VH:         Set sh = Worksheets("sheet1")
        Case NW And Not VH:     Set sh = Worksheets("sheet2")
        Case Not NW And VH:     Set sh = Worksheets("sheet3")
        Case Not NW And Not VH: Set sh = Worksheets("sheet4")
    End Select
    
    Place data on sh

  4. #4
    Registered User
    Join Date
    11-11-2008
    Location
    Wilmington
    Posts
    26
    see guys all i needed was little boost!

    Thanks to both of you, I like to know i wasnt' oo far out in left field, but the case seems like it will work

    THANKS!!!!!

  5. #5
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689
    Or
    Set sh = IIf(bNW, IIf(bVH, Sheet1, Sheet2), IIf(bVH(Sheet3, Sheet4)))

  6. #6
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259
    Hello eighty2scrambler,

    Here is another way using an algorithm derived from the logic expression...
      Sheets((Abs(Not NW) * 2 + Abs(Not VH)) + 1).Select
    Sincerely,
    Leith Ross

  7. #7
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689
    Or
    Sheets(1 - bNW * 2 - bVH).Select

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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