# "End If Without Block If" in Calculate Angle Of TAN

#### Do Vo Anh

##### New Member
Can anyone help me solve these problem?

Sub Calculate()
Dim i As Long
Dim ia As Long
Dim DistanceOfX As Double
Dim DistanceOfY As Double
Dim Atan As Double
Range("A43:A83").Value = DistanceOfX
If Range("B43:B83").Value = 2.875 Then DistanceOfY = -1.375
End If

xrad = -(2.25 - (DistanceOfY * DistanceOfY)) / (DistanceOfX * DistanceOfY)

Range("E43:E83").Value = Atan

End Sub

### Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.
Can anyone help me solve these problem?

If Range("B43:B83").Value = 2.875 Then DistanceOfY = -1.375
End If
There are two forms of If..Then, a single line one that looks like this...

If {logical expression} Then {action statement}

and the other that looks like this...

If {logical expression} Then
{action statements}
End If

In the above part of your code, your If..Then is of the single line kind, so the End If on the next line does not have an If..Then partner, and so it generates an error. You should remove it.

So how can i solve these problem sir? I want to calculate the angle of tan using that formula ( xrad = -(2.25 - (DistanceOfY * DistanceOfY)) / (DistanceOfX * DistanceOfY) )

All Values of DistanceOfX, DistanceOfX in the same Range. But the Value of DistanceOfY has the same value, but i cant use this in my calculate so thats why i'm changing it to another Value that can be use.. So how can i do it, sir?

I am not 100% sure what that code is supposed to be doing, but I so see another problem with your code. This line cannot work...

If Range("B43:B83").Value = 2.875 Then DistanceOfY = -1.375

because you are asking if 41 things are equal to one thing. Are you trying to set DistanceOfY equal to -1.375 if any cell in range B43:B83 equals 2.875? If so, you would need to do that like this...
Code:
``If Not Range("B43:B83").Find(2.875, , , xlWhole) Is Nothing Then  DistanceOfY = -1.375``

Replies
3
Views
234
Replies
13
Views
3K
Replies
1
Views
702
Replies
6
Views
177
Replies
6
Views
795

1,203,472
Messages
6,055,612
Members
444,803
Latest member
retrorocket129

### We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.

### Which adblocker are you using?

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

### Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

### Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back