Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 15
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,939
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 15
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Countif Conditions - Use of conditions that vary by cell value JonTarg Excel Discussion (Misc queries) 1 May 30th 08 01:21 PM
2 Conditions + Sum of a colum matching those conditions Jeffa Excel Worksheet Functions 5 June 8th 07 12:14 AM
shade cells based on conditions - i have more than 3 conditions Mo2 Excel Worksheet Functions 3 March 30th 07 07:19 AM
Two Conditions Xandlyn Excel Discussion (Misc queries) 5 September 23rd 05 08:24 PM
How to multiple conditions to validate more than 2 conditions to . Bhuvana Govind Excel Worksheet Functions 1 January 28th 05 07:07 PM


All times are GMT +1. The time now is 08:50 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright 2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"