I am attempting to recollect my college programming courses to remember my coding and I am stumped by my if else statement. I have posted the code below:<o
> </o
>
Sub CalculateAQI()
'
'
'User inputs a numerical value located in cell (1,6) and then runs this macro
Cells(1, 6).Value = I
If 0 <= I <= 15.4 Then
IH = 50 And IL = 0 And BPH = 12 And BPL = 0
Else
If 15.5 <= I <= 40.4 Then
IH = 100 And IL = 51 And BPH = 35.4 And BPL = 12.1
Else
If 40.5 <= I <= 65.4 Then
IH = 150 And IL = 101 And BPH = 55.4 And BPL = 35.5
Else
If 65.5 <= I <= 150.4 Then
IH = 200 And IL = 151 And BPH = 150.4 And BPL = 55.5
Else
If 150.5 <= I <= 250.4 Then
IH = 300 And IL = 201 And BPH = 250.4 And BPL = 150.5
Else
If 250.5 <= I <= 350.4 Then
IH = 400 And IL = 301 And BPH = 650 And BPL = 250.5
Else
If 350.5 <= I <= 500.4 Then
IH = 500 And IL = 401 And BPH = 650 And BPL = 250.5
End If
'The destination of the final numerical value should be placed in Cell(3,6)
Cells(3, 6).Value = [(IH - IL)/(BPH -BPL)] * (I - BPL) + IL
'
End Sub
<o
> </o
>
There is an error once you reach the end sub saying that Idid not end the If statement which I thought I did but if someone could assistme, I would greatly appreciate it.<o
></o
>
Jedit<o
></o
>


Sub CalculateAQI()
'
'
'User inputs a numerical value located in cell (1,6) and then runs this macro
Cells(1, 6).Value = I
If 0 <= I <= 15.4 Then
IH = 50 And IL = 0 And BPH = 12 And BPL = 0
Else
If 15.5 <= I <= 40.4 Then
IH = 100 And IL = 51 And BPH = 35.4 And BPL = 12.1
Else
If 40.5 <= I <= 65.4 Then
IH = 150 And IL = 101 And BPH = 55.4 And BPL = 35.5
Else
If 65.5 <= I <= 150.4 Then
IH = 200 And IL = 151 And BPH = 150.4 And BPL = 55.5
Else
If 150.5 <= I <= 250.4 Then
IH = 300 And IL = 201 And BPH = 250.4 And BPL = 150.5
Else
If 250.5 <= I <= 350.4 Then
IH = 400 And IL = 301 And BPH = 650 And BPL = 250.5
Else
If 350.5 <= I <= 500.4 Then
IH = 500 And IL = 401 And BPH = 650 And BPL = 250.5
End If
'The destination of the final numerical value should be placed in Cell(3,6)
Cells(3, 6).Value = [(IH - IL)/(BPH -BPL)] * (I - BPL) + IL
'
End Sub
<o


There is an error once you reach the end sub saying that Idid not end the If statement which I thought I did but if someone could assistme, I would greatly appreciate it.<o


Jedit<o

