Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default compile error: block if without end if

I have an intro course with C++ but a newbie user with VB. I googled th
error, which seems pretty simple in itself, but I didn't resolve it
The error is:

*Block If without End If*

and the code, copied right out of VB:


Function UtilizationRank(Utilization As Integer) As Integer

If Utilization 90 Then
UtilizationRank = 1
If Utilization <= 90 And Utilization 75 Then
UtilizationRank = 2
If Utilization <= 75 And Utilization 50 Then
UtilizationRank = 3
If Utilization <= 50 And Untilization <= 1 Then
UtilizationRank = 4
If Utilization = 0 Then
UtilizationRank = 5
End If

End Function



Like I said, newbie prob. I'm not sure about whitespace issues either
Solve my problem, give me pointers. Thanks

--
Message posted from http://www.ExcelForum.com

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default compile error: block if without end if

whelanj,

The correct syntax is

If Utilization 90 Then
UtilizationRank = 1
ElseIf Utilization <= 90 And Utilization 75 Then
UtilizationRank = 2
...
End If


---
Message posted from http://www.ExcelForum.com/

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 157
Default compile error: block if without end if

Hi Whelanj,

Just to tell u in ur code u have put "If Utilization <= 50 And Untilization
<= 1 Then" . This might be incorrect as if Untilization <= 1 then it will
be automatically less than 50, so please modify the same to "If Utilization
<= 50 And Untilization = 1 Then"

As, Jgett has said use

If ..... then

....

Else

If ..... then

...

Else

and so on.


Or, U can alternatively use


If .... then

....

End if

If .... then

....

End if



and so on.
"whelanj " wrote in message
...
I have an intro course with C++ but a newbie user with VB. I googled the
error, which seems pretty simple in itself, but I didn't resolve it.
The error is:

*Block If without End If*

and the code, copied right out of VB:


Function UtilizationRank(Utilization As Integer) As Integer

If Utilization 90 Then
UtilizationRank = 1
If Utilization <= 90 And Utilization 75 Then
UtilizationRank = 2
If Utilization <= 75 And Utilization 50 Then
UtilizationRank = 3
If Utilization <= 50 And Untilization <= 1 Then
UtilizationRank = 4
If Utilization = 0 Then
UtilizationRank = 5
End If

End Function



Like I said, newbie prob. I'm not sure about whitespace issues either.
Solve my problem, give me pointers. Thanks.


---
Message posted from http://www.ExcelForum.com/



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default compile error: block if without end if

thanks... i may have another problem but look for that in a late
post..

--
Message posted from http://www.ExcelForum.com

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default compile error: block if without end if

After the first If use ElseIf rather than IF

--

HTH

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

"whelanj " wrote in message
...
I have an intro course with C++ but a newbie user with VB. I googled the
error, which seems pretty simple in itself, but I didn't resolve it.
The error is:

*Block If without End If*

and the code, copied right out of VB:


Function UtilizationRank(Utilization As Integer) As Integer

If Utilization 90 Then
UtilizationRank = 1
If Utilization <= 90 And Utilization 75 Then
UtilizationRank = 2
If Utilization <= 75 And Utilization 50 Then
UtilizationRank = 3
If Utilization <= 50 And Untilization <= 1 Then
UtilizationRank = 4
If Utilization = 0 Then
UtilizationRank = 5
End If

End Function



Like I said, newbie prob. I'm not sure about whitespace issues either.
Solve my problem, give me pointers. Thanks.


---
Message posted from http://www.ExcelForum.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
help with this error-Compile error: cant find project or library JackR Excel Discussion (Misc queries) 2 June 10th 06 09:09 PM
Compile Error: Block If without End if [email protected] Excel Discussion (Misc queries) 4 March 3rd 06 06:30 PM
How do I get rid of "Compile error in hidden module" error message David Excel Discussion (Misc queries) 4 January 21st 05 11:39 PM
Compile error in hidden module error Melissa Zebrowski Excel Programming 3 February 20th 04 01:29 PM


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