Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 18
Default if then or statement in a macro

TIA


I'm familiar with writing an IF THEN OR or AND statement in a formula,
but i don't know how to write an OR statement in a macro.

I've created a spreadsheet where the user can use one of two different
text boxes to input data. Box A can be compared with a variable (some
of you have helped me with that already).

I need the macro to determine if data in either box is matches either
of two variables, then an even takes place.

so, a mathamatical problem is given. users have the choice of
answering the problem in either of two ways. i need an a statement
that is something like:

if a is true or b is true then .......
but, i don't know how to do it with a macro.

If CInt(checks.Text) = x1 Then ........... (this works great)

i need something like If CInt(checks.Text) = x1 Or CInt(cash.Text) =
x2 then .......... but i don't know how write it and can't find it in
my help books. my help book mentions OR statements but has no examples
or real data.

thanks again everyone for your help.
jasonK.


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,339
Default if then or statement in a macro


Try:

If application.or(CInt(checks.Text) = x1 ,CInt(checks.Text) = x2) then

HTH

"JasonK" wrote:

TIA


I'm familiar with writing an IF THEN OR or AND statement in a formula,
but i don't know how to write an OR statement in a macro.

I've created a spreadsheet where the user can use one of two different
text boxes to input data. Box A can be compared with a variable (some
of you have helped me with that already).

I need the macro to determine if data in either box is matches either
of two variables, then an even takes place.

so, a mathamatical problem is given. users have the choice of
answering the problem in either of two ways. i need an a statement
that is something like:

if a is true or b is true then .......
but, i don't know how to do it with a macro.

If CInt(checks.Text) = x1 Then ........... (this works great)

i need something like If CInt(checks.Text) = x1 Or CInt(cash.Text) =
x2 then .......... but i don't know how write it and can't find it in
my help books. my help book mentions OR statements but has no examples
or real data.

thanks again everyone for your help.
jasonK.



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 18
Default if then or statement in a macro

toppers,
the comma didn't work.
any other ideas?
thanks,
jasonk


On Wed, 12 Apr 2006 00:53:01 -0700, Toppers
wrote:


Try:

If application.or(CInt(checks.Text) = x1 ,CInt(checks.Text) = x2) then

HTH

"JasonK" wrote:

TIA


I'm familiar with writing an IF THEN OR or AND statement in a formula,
but i don't know how to write an OR statement in a macro.

I've created a spreadsheet where the user can use one of two different
text boxes to input data. Box A can be compared with a variable (some
of you have helped me with that already).

I need the macro to determine if data in either box is matches either
of two variables, then an even takes place.

so, a mathamatical problem is given. users have the choice of
answering the problem in either of two ways. i need an a statement
that is something like:

if a is true or b is true then .......
but, i don't know how to do it with a macro.

If CInt(checks.Text) = x1 Then ........... (this works great)

i need something like If CInt(checks.Text) = x1 Or CInt(cash.Text) =
x2 then .......... but i don't know how write it and can't find it in
my help books. my help book mentions OR statements but has no examples
or real data.

thanks again everyone for your help.
jasonK.




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,339
Default if then or statement in a macro

Works OK for me! I don't undrstand the "comma didn't work"

"JasonK" wrote:

toppers,
the comma didn't work.
any other ideas?
thanks,
jasonk


On Wed, 12 Apr 2006 00:53:01 -0700, Toppers
wrote:


Try:

If application.or(CInt(checks.Text) = x1 ,CInt(checks.Text) = x2) then

HTH

"JasonK" wrote:

TIA


I'm familiar with writing an IF THEN OR or AND statement in a formula,
but i don't know how to write an OR statement in a macro.

I've created a spreadsheet where the user can use one of two different
text boxes to input data. Box A can be compared with a variable (some
of you have helped me with that already).

I need the macro to determine if data in either box is matches either
of two variables, then an even takes place.

so, a mathamatical problem is given. users have the choice of
answering the problem in either of two ways. i need an a statement
that is something like:

if a is true or b is true then .......
but, i don't know how to do it with a macro.

If CInt(checks.Text) = x1 Then ........... (this works great)

i need something like If CInt(checks.Text) = x1 Or CInt(cash.Text) =
x2 then .......... but i don't know how write it and can't find it in
my help books. my help book mentions OR statements but has no examples
or real data.

thanks again everyone for your help.
jasonK.





  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default if then or statement in a macro


Did you try the code you suggested? It should work...

If CInt(checks.Text) = x1 Or CInt(cash.Text) = x2 then


code...


end if


--
Zurn
------------------------------------------------------------------------
Zurn's Profile: http://www.excelforum.com/member.php...o&userid=14645
View this thread: http://www.excelforum.com/showthread...hreadid=532179



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 18
Default if then or statement in a macro

the actual code is:


If CInt(checks.Text) = x1 Or CInt(cash.Text) = x2 Then

this doesn't work.
i reviewed my variable to make sure it was proper, and it is.
i can't figure this out. i'm sure there is a way to write an IF,
THEN, OR statement in a macro, but i can't figure it out.
please offer more suggestions if you can.
thanks again,
jasonk


On Wed, 12 Apr 2006 02:58:00 -0500, Zurn
wrote:


Did you try the code you suggested? It should work...

If CInt(checks.Text) = x1 Or CInt(cash.Text) = x2 then


code...


end if


  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,339
Default if then or statement in a macro

I tried your last posted code and it worked for me (with textboxes named
"Checks" and "Cash"). Error occurs if either are blank.


Sub a()
If Application.Or(CInt(Checks.Text) = 1, CInt(Cash.Text) = 2) Then
MsgBox "OR"
End If

This worked too ....

x1 = 1
x2 = 2
If CInt(Checks.Text) = x1 Or CInt(Cash.Text) = x2 Then
MsgBox "OR"
End If

End Sub
"JasonK" wrote:

the actual code is:


If CInt(checks.Text) = x1 Or CInt(cash.Text) = x2 Then

this doesn't work.
i reviewed my variable to make sure it was proper, and it is.
i can't figure this out. i'm sure there is a way to write an IF,
THEN, OR statement in a macro, but i can't figure it out.
please offer more suggestions if you can.
thanks again,
jasonk


On Wed, 12 Apr 2006 02:58:00 -0500, Zurn
wrote:


Did you try the code you suggested? It should work...

If CInt(checks.Text) = x1 Or CInt(cash.Text) = x2 then


code...


end if



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
If Statement to run a macro Secret Squirrel Excel Discussion (Misc queries) 4 July 15th 08 03:43 PM
If statement in macro punter Excel Discussion (Misc queries) 3 June 20th 06 12:23 PM
Macro and If Statement SATB Excel Discussion (Misc queries) 2 December 3rd 04 04:46 PM
IF statement macro Qwerty Excel Programming 1 January 11th 04 09:22 PM
Macro statement Sheela Excel Programming 1 September 2nd 03 10:17 AM


All times are GMT +1. The time now is 08:31 AM.

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"