LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,124
Default Error: Block If without End If

try it like this or use else if. Look in the help index
'I tested
'If p 2 Then Cells(1, "g") = 2: Cells(2, "g") = 3

If p 90 Then ns = 0:nl = 2
If p 70 Then ns = 1:nl = 1

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

wrote in message
oups.com...

I keep getting the error message "Block If without End If" when I try
to run the following code. Please help!


Sub utahvalleytours()

'define variables
Dim p As Integer
Dim h As Double
Dim ech As Double
Dim ns As Integer
Dim nl As Integer
Dim se As Double
Dim le As Double
Dim sehc As Double
Dim lehc As Double
Dim stp As Double
Dim ltp As Double
Dim tp As Double
Dim sbp As Double
Dim lbp As Double
Dim ehp As Double


'input variables
p = Range("d7").Value
h = Range("d9").Value
sbp = Range("h10").Value
lbp = Range("h11").Value
ehp = Range("h13").Value




If p 90 Then
ns = 0
nl = 2
If p 70 Then
ns = 1
nl = 1
If p 55 Then
ns = 2
nl = 0
If p 35 Then
ns = 0
nl = 1
Else
ns = 1
nl = 0
End If

'calculate
se = ns * sbp
le = nl * lbp

If h <= 5 Then
sehc = 0
lehc = 0
ech = 0
Else
ech = h - 5
End If

If ech < 4 Then
sehc = ech * ehp * se
lehc = ech * ehp * le
Else
sehc = 4 * ehp * se
lehc = 4 * ehp * le
End If

'compute
stp = se + sehc
ltp = le + lehc
tp = stp + ltp

'output
Range("d14").Value = ech
Range("c18").Value = ns
Range("c20").Value = se
Range("c22").Value = sehc
Range("c24").Value = stp
Range("e18").Value = nl
Range("e20").Value = le
Range("e22").Value = lehc
Range("e24").Value = ltp
Range("d27").Value = tp


End Sub


 
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
end if without block if error stewart Excel Programming 4 September 17th 07 12:01 AM
End If without Block If Error Help Bull Excel Programming 6 April 30th 07 08:24 PM
Compile error: End If without block IF urkec Excel Programming 0 March 28th 07 12:21 AM
VBA error - End If without Block If Jane Excel Worksheet Functions 2 December 6th 05 06:00 PM
Error - End If Without Block Gauthier[_2_] Excel Programming 6 September 26th 04 05:14 AM


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