VBA If condition

  • Thread starter Thread starter Dan E
  • Start date Start date
D

Dan E

I want to test for something like this -

If Cells (oRow.Row, "AT").Value = "1" OR "2" OR "3" Then
Cells(oRow.Row, "BA").Value = 0
ElseIf....

buy am unclear how to express the OR conditions in VBA.

All help gratefully received and acknowledged!

TIA,

Dan
 
Try something like

If Cells(oRow.Row,"AT").Value = "1" Or _
Cells(oRow.Row,"AT").Value = "2" Or _
Cells(oRow.Row,"AT").Value= "3" Then
Cells(oRow.Row,"BA").Value = 0
.....


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
 
Many thanks, Chip!

Dan
Chip Pearson said:
Try something like

If Cells(oRow.Row,"AT").Value = "1" Or _
Cells(oRow.Row,"AT").Value = "2" Or _
Cells(oRow.Row,"AT").Value= "3" Then
Cells(oRow.Row,"BA").Value = 0
....


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
 
You may want to look at VBA's help for "select case"

select case cells(orow.row,"AT").value
case is = 1, 2, 3
cells(orow.row,"BA").value = 0
end select

(Did you really want text 1, 2, 3 ("1", "2", "3")?)
 
Back
Top