ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   using AND and OR as an if then condition (https://www.excelbanter.com/excel-programming/288664-using-if-then-condition.html)

Frank Brown[_2_]

using AND and OR as an if then condition
 
Hi,
I am trying to create an if then statment that uses as its condition.

IF active.cell.value = (A or B) and Activecell(offset(0,3).value = C
then execute.

I am having problems with (A or B).

I could use some help with the context of the statement. A,B, and C
are all different ComboBox values. This is part of a look up routine
that sets down through one sheet and then copies values to another
sheet.

Thanks in advance,
Frank

Bob Phillips[_6_]

using AND and OR as an if then condition
 
Frank,

Try this

With ActiveCell
If (.Value = A OR .Value = B) AND .Offset(0,3).Value = C Then
'...
End If
End With

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Frank Brown" wrote in message
om...
Hi,
I am trying to create an if then statment that uses as its condition.

IF active.cell.value = (A or B) and Activecell(offset(0,3).value = C
then execute.

I am having problems with (A or B).

I could use some help with the context of the statement. A,B, and C
are all different ComboBox values. This is part of a look up routine
that sets down through one sheet and then copies values to another
sheet.

Thanks in advance,
Frank




Beto[_3_]

using AND and OR as an if then condition
 
Frank Brown wrote:

Hi,
I am trying to create an if then statment that uses as its condition.

IF active.cell.value = (A or B) and Activecell(offset(0,3).value = C
then execute.


Correct syntax would be:

If (ActiveCell.Value = A Or Activecell.Value = B) And _
ActiveCell.Offset(0,3).Value = C Then
' Code if condition is true
End If

Regards,
--
Beto
Reply: Erase between the dot (inclusive) and the @.
Responder: Borra la frase obvia y el punto previo.



All times are GMT +1. The time now is 01:23 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com