+ Reply to Thread
Results 1 to 3 of 3

how to use 2 conditions in if

  1. #1
    Sergei D
    Guest

    how to use 2 conditions in if

    I am writing a macro that would importa data from a transaction file to my
    report file. I need to specify 2 conditions for the loopup. Here is an
    examply (dummy) of what I will be writing. Please help to specify 2
    conditions. thanks
    Dim cell As Range
    Dim str As String

    For Each cell In Range("a8:a30")
    If cell = 1122 Then
    cell.Select
    With Selection.Interior
    .ColorIndex = 6
    .Pattern = xlSolid
    End With
    ElseIf Not IsEmpty(cell.Value) Then
    cell.Select
    With Selection.Interior
    .ColorIndex = 5
    .Pattern = xlSolid
    End With
    Else: Range("a33").Select
    ActiveCell.FormulaR1C1 = "end of transactions"

    End If
    Next cell
    End Sub


    --
    Sergei D

  2. #2
    Don Guillett
    Guest

    Re: how to use 2 conditions in if

    You didn't say where or what so try something like

    For Each cell In Range("a8:a30")
    If cell> = 1122 and cell<1200 Then
    With cell.Interior
    .ColorIndex = 6
    .Pattern = xlSolid
    End With
    ElseIf Not IsEmpty(cell.Value) Then
    With cell.Interior
    .ColorIndex = 5
    .Pattern = xlSolid
    End With
    Else: Range("a33").value= "end of transactions"
    End If
    Next cell


    --
    Don Guillett
    SalesAid Software
    [email protected]
    "Sergei D" <[email protected]> wrote in message
    news:[email protected]...
    >I am writing a macro that would importa data from a transaction file to my
    > report file. I need to specify 2 conditions for the loopup. Here is an
    > examply (dummy) of what I will be writing. Please help to specify 2
    > conditions. thanks
    > Dim cell As Range
    > Dim str As String
    >
    > For Each cell In Range("a8:a30")
    > If cell = 1122 Then
    > cell.Select
    > With Selection.Interior
    > .ColorIndex = 6
    > .Pattern = xlSolid
    > End With
    > ElseIf Not IsEmpty(cell.Value) Then
    > cell.Select
    > With Selection.Interior
    > .ColorIndex = 5
    > .Pattern = xlSolid
    > End With
    > Else: Range("a33").Select
    > ActiveCell.FormulaR1C1 = "end of transactions"
    >
    > End If
    > Next cell
    > End Sub
    >
    >
    > --
    > Sergei D




  3. #3
    Bob Phillips
    Guest

    Re: how to use 2 conditions in if

    Do you mean

    If cell = 1122 Or cell = 2233 Then


    --
    HTH

    Bob Phillips

    (replace somewhere in email address with gmail if mailing direct)

    "Sergei D" <[email protected]> wrote in message
    news:[email protected]...
    > I am writing a macro that would importa data from a transaction file to my
    > report file. I need to specify 2 conditions for the loopup. Here is an
    > examply (dummy) of what I will be writing. Please help to specify 2
    > conditions. thanks
    > Dim cell As Range
    > Dim str As String
    >
    > For Each cell In Range("a8:a30")
    > If cell = 1122 Then
    > cell.Select
    > With Selection.Interior
    > .ColorIndex = 6
    > .Pattern = xlSolid
    > End With
    > ElseIf Not IsEmpty(cell.Value) Then
    > cell.Select
    > With Selection.Interior
    > .ColorIndex = 5
    > .Pattern = xlSolid
    > End With
    > Else: Range("a33").Select
    > ActiveCell.FormulaR1C1 = "end of transactions"
    >
    > End If
    > Next cell
    > End Sub
    >
    >
    > --
    > Sergei D




+ 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