#1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 96
Default If function problem

Can someone explain to me why my Excel 2003 is not recognizing ( If )?
I've tried several codes with the If function and my code won't run.
If (this or that) Then...

and

If (this or that) Then....
Elseif (this or that) Then......
End If

In the first case the debugger says (End If without a block If).

In the second case the debugger says (ElseIf without a block If).
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 3,942
Default If function problem

hi
usually means what it says. but we are not going to know untill you post
your code.

regards
FSt1

"chrisnsmith" wrote:

Can someone explain to me why my Excel 2003 is not recognizing ( If )?
I've tried several codes with the If function and my code won't run.
If (this or that) Then...

and

If (this or that) Then....
Elseif (this or that) Then......
End If

In the first case the debugger says (End If without a block If).

In the second case the debugger says (ElseIf without a block If).

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 5,934
Default If function problem

Post your ACTUAL code, not that pseudo-code... it is very hard to debug code
when you can't see the code.

--
Rick (MVP - Excel)


"chrisnsmith" wrote in message
...
Can someone explain to me why my Excel 2003 is not recognizing ( If )?
I've tried several codes with the If function and my code won't run.
If (this or that) Then...

and

If (this or that) Then....
Elseif (this or that) Then......
End If

In the first case the debugger says (End If without a block If).

In the second case the debugger says (ElseIf without a block If).


  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 22,906
Default If function problem

Post the code that fails.


Gord Dibben MS Excel MVP

On Fri, 6 Feb 2009 12:33:01 -0800, chrisnsmith
wrote:

Can someone explain to me why my Excel 2003 is not recognizing ( If )?
I've tried several codes with the If function and my code won't run.
If (this or that) Then...

and

If (this or that) Then....
Elseif (this or that) Then......
End If

In the first case the debugger says (End If without a block If).

In the second case the debugger says (ElseIf without a block If).


  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 225
Default If function problem

I suspect the full code looks something like this:

If x = 1 or x=2 then y = 3
ElseIf x = 4 or x = 5 then y = 6
End if

If so, it should be

If x = 1 or x=2 then
y = 3
ElseIf x = 4 or x = 5 then
y = 6
End if

Incidentally, there is no need in VB/VBA to enclose the
conditions in parentheses; IMHO it needlessly clutters
up the code.




On 6 Feb, 20:33, chrisnsmith
wrote:
Can someone explain to me why my Excel 2003 is not recognizing ( If )?
I've tried several codes with the If function and my code won't run.
If (this or that) Then...

and

If (this or that) Then....
Elseif (this or that) Then......
End If

In the first case the debugger says (End If without a block If).

In the second case the debugger says (ElseIf without a block If).




  #6   Report Post  
Member
 
Location: Sweden
Posts: 30
Default

You must be familiar with the usual VB codes to be able to use macros.
As you are facing a problem related to conditional statement, I will describe briefly about its syntax

If you are just using one if statement then the syntax would be like
IF condition1 then
<statements
………………………
End If

Now if you are using nested If-Else structure then the syntax would be like
IF condition1 then
<statements
………………….
ElseIF condition2 then
|<statements
……………………..
End IF


Hope you get it.....


Chris
------
Convert your Excel spreadsheet into an online calculator.
http://www.spreadsheetconverter.com
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
OR function problem luvnrocs Excel Worksheet Functions 16 March 7th 08 06:58 PM
Problem with function Mike Excel Discussion (Misc queries) 8 June 19th 07 02:53 PM
Problem with IF function.... neilcarden Excel Worksheet Functions 2 March 27th 07 04:32 PM
function problem chindo Excel Worksheet Functions 6 November 10th 05 02:29 PM
IF function problem dvonj Excel Worksheet Functions 13 March 10th 05 01:13 PM


All times are GMT +1. The time now is 05:57 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"