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

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default 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" wrote in message
...
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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,124
Default 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

"Sergei D" wrote in message
...
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
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
More than 3 conditions Eric Excel Discussion (Misc queries) 0 January 14th 08 09:58 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
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 10:13 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"