or statement in vba?

  • I have 2 if statements that work fine separetly, but I can't get them to both work.. I need it basically say"
    if either one of the if statements is true, then blah blah..
    i tried using the else if statement but it doesn't seem to work just right.. is there any way to use an OR statment there? it won't let me, but i may be doing it wrong... THanks!


    If ActiveCell.Offset(8, -7) = "Steve" And ActiveCell.Offset(-1, -7) = "home" Then
    ElseIf ActiveCell.Offset(-1, -7) <> "100" And ActiveCell.Offset(8, -7) = "home" Then
    Range(ActiveCell(), ActiveCell.Offset(8, 0)).Select
    Else: Range(ActiveCell(), ActiveCell.Offset(7, 0)).Select
    End If




    so basically this works:
    If ActiveCell.Offset(8, -7) = "Steve" And ActiveCell.Offset(-1, -7) = "home" Then
    Range(ActiveCell(), ActiveCell.Offset(8, 0)).Select
    Else: Range(ActiveCell(), ActiveCell.Offset(7, 0)).Select
    End If



    this works:


    If ActiveCell.Offset(-1, -7) <> "100" And ActiveCell.Offset(8, -7) = "home" Then
    Range(ActiveCell(), ActiveCell.Offset(8, 0)).Select
    Else: Range(ActiveCell(), ActiveCell.Offset(7, 0)).Select
    End If


    but i can't get them to work together.. any help is appreciated. Thanks!

  • i think i've figured it out.. i needed the statement after the first if.. so:


    If ActiveCell.Offset(8, -7) = "Steve" And ActiveCell.Offset(-1, -7) = "home" Then


    Range(ActiveCell(), ActiveCell.Offset(8, 0)).Select


    ElseIf ActiveCell.Offset(-1, -7) <> "100" And ActiveCell.Offset(8, -7) = "home" Then
    Range(ActiveCell(), ActiveCell.Offset(8, 0)).Select
    Else: Range(ActiveCell(), ActiveCell.Offset(7, 0)).Select
    End If


    guess that's all i needed was a break from it for a minute.. thanks anyways!

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!