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


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 162
Default 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-




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 58
Default 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-






  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default 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-


.

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
question related to merging multiple statements Dharmesh[_2_] Excel Worksheet Functions 5 May 1st 10 03:10 PM
IF Statements (Mutliple Statements) Deezel Excel Worksheet Functions 3 October 19th 06 06:13 AM
If Statements Question bodhisatvaofboogie Excel Discussion (Misc queries) 2 May 3rd 06 07:37 PM
Another question concerning IF statements Jessica Excel Discussion (Misc queries) 1 July 14th 05 06:56 PM
Question concerning IF statements Jessica Excel Discussion (Misc queries) 1 July 14th 05 06:50 PM


All times are GMT +1. The time now is 02:18 PM.

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

About Us

"It's about Microsoft Excel"