ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Question about using AND or OR with If-Then statements (https://www.excelbanter.com/excel-programming/285844-question-about-using-if-then-statements.html)

TBA[_2_]

Question about using AND or OR with If-Then statements
 
Windows 2k Pro
Excel 2000

What is the syntax for this situation:

If a = x and b = y Then
[code]
End If

Apparently the above doesn't work. All help appreciated.

-gk-



Norman Harker

Question about using AND or OR with If-Then statements
 
Hi TBA!

Try:

Sub test()
If Range("A4") = 7 And Range("B4") = 4 Then
Range("C4") = 11
End If
End Sub

Same principle would apply to Or

But what is your specific problem as you seem to have it OK?
--
Regards
Norman Harker MVP (Excel)
Sydney, Australia

Excel and Word Function Lists (Classifications, Syntax and Arguments)
available free to good homes.
"TBA" wrote in message
...
Windows 2k Pro
Excel 2000

What is the syntax for this situation:

If a = x and b = y Then
[code]
End If

Apparently the above doesn't work. All help appreciated.

-gk-





TBA[_2_]

Question about using AND or OR with If-Then statements
 
Silly me...

I had tried this

If a = 5 OR 7 OR 9 Then
......

doh!!

Thanks for the slap upside the head. ;)

-gk-

"Norman Harker" wrote in message
...
Hi TBA!

Try:

Sub test()
If Range("A4") = 7 And Range("B4") = 4 Then
Range("C4") = 11
End If
End Sub

Same principle would apply to Or

But what is your specific problem as you seem to have it OK?
--
Regards
Norman Harker MVP (Excel)
Sydney, Australia

Excel and Word Function Lists (Classifications, Syntax and Arguments)
available free to good homes.
"TBA" wrote in message
...
Windows 2k Pro
Excel 2000

What is the syntax for this situation:

If a = x and b = y Then
[code]
End If

Apparently the above doesn't work. All help appreciated.

-gk-







Norman Harker

Question about using AND or OR with If-Then statements
 
Hi TBA!

Thanks for thanks and confirmation it works OK is always useful for
searchers.

We don't award slaps upside the heads on these groups except to
ourselves. Good job as I'd be like a cod on Saturday night in Halifax
by now; well and truly battered!

--
Regards
Norman Harker MVP (Excel)
Sydney, Australia

Excel and Word Function Lists (Classifications, Syntax and Arguments)
available free to good homes.
"TBA" wrote in message
...
Silly me...

I had tried this

If a = 5 OR 7 OR 9 Then
.....

doh!!

Thanks for the slap upside the head. ;)

-gk-

"Norman Harker" wrote in message
...
Hi TBA!

Try:

Sub test()
If Range("A4") = 7 And Range("B4") = 4 Then
Range("C4") = 11
End If
End Sub

Same principle would apply to Or

But what is your specific problem as you seem to have it OK?
--
Regards
Norman Harker MVP (Excel)
Sydney, Australia

Excel and Word Function Lists (Classifications, Syntax and

Arguments)
available free to good homes.
"TBA" wrote in message
...
Windows 2k Pro
Excel 2000

What is the syntax for this situation:

If a = x and b = y Then
[code]
End If

Apparently the above doesn't work. All help appreciated.

-gk-









Patrick Molloy[_5_]

Question about using AND or OR with If-Then statements
 
As is the code sample is fine. Why do you think that it
does not work?


Sub test()
Dim a As Long, b As Long, x As Long, y As Long
a = 5
x = 5
b = 3
y = 3
If a = x And b = y Then
MsgBox "hello world!"
End If
End Sub




-----Original Message-----
Windows 2k Pro
Excel 2000

What is the syntax for this situation:

If a = x and b = y Then
[code]
End If

Apparently the above doesn't work. All help appreciated.

-gk-


.



All times are GMT +1. The time now is 12:22 AM.

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