Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
how to use 2 conditions in if
This is a follow up on my last question. I am sorry I did not formulate my
question right. In my example I have only one range (a8:a30). I need it, after it matches the cell = 1122 in column A, to go to column B and meet another condition. Basically, I need it to match column A with column B and then I want it to evaluate IF. 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
Posted to microsoft.public.excel.programming
|
|||
|
|||
how to use 2 conditions in if
If cell = 1122 Then
If cell.Value = cell.Offset(0,1).Value Then .... End If -- HTH Bob Phillips (replace somewhere in email address with gmail if mailing direct) "Sergei D" wrote in message ... This is a follow up on my last question. I am sorry I did not formulate my question right. In my example I have only one range ("a8:a30"). I need it, after it matches the cell = 1122 in column A, to go to column B and meet another condition. Basically, I need it to match column A with column B and then I want it to evaluate IF. 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
Posted to microsoft.public.excel.programming
|
|||
|
|||
how to use 2 conditions in if
Y have a range object cell which you are using to traverse the range A8:A30.
If I understand you correctly you want to check the value of cell and cell offset one column to the right (Column B) if cell.value = 1122 and cell.offset(0,1).value = 2211 then end if -- HTH... Jim Thomlinson "Sergei D" wrote: This is a follow up on my last question. I am sorry I did not formulate my question right. In my example I have only one range (a8:a30). I need it, after it matches the cell = 1122 in column A, to go to column B and meet another condition. Basically, I need it to match column A with column B and then I want it to evaluate IF. 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 |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
how to use 2 conditions in if
Thank you so much. I can not believe this is so easy... I spent a lot of time
trying to do the same with many lines of code which did not work. This works perfectly. Thanks! -- Sergei D "Jim Thomlinson" wrote: Y have a range object cell which you are using to traverse the range A8:A30. If I understand you correctly you want to check the value of cell and cell offset one column to the right (Column B) if cell.value = 1122 and cell.offset(0,1).value = 2211 then end if -- HTH... Jim Thomlinson "Sergei D" wrote: This is a follow up on my last question. I am sorry I did not formulate my question right. In my example I have only one range (a8:a30). I need it, after it matches the cell = 1122 in column A, to go to column B and meet another condition. Basically, I need it to match column A with column B and then I want it to evaluate IF. 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 |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Countif Conditions - Use of conditions that vary by cell value | Excel Discussion (Misc queries) | |||
2 Conditions + Sum of a colum matching those conditions | Excel Worksheet Functions | |||
shade cells based on conditions - i have more than 3 conditions | Excel Worksheet Functions | |||
Two Conditions | Excel Discussion (Misc queries) | |||
How to multiple conditions to validate more than 2 conditions to . | Excel Worksheet Functions |