Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() 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 |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
end if without block if error | Excel Programming | |||
End If without Block If Error Help | Excel Programming | |||
Compile error: End If without block IF | Excel Programming | |||
VBA error - End If without Block If | Excel Worksheet Functions | |||
Error - End If Without Block | Excel Programming |