Give this a shot. I used fanpages' testing sub from the other question and it all matches:

Function F(xi As Double, x1 As Double, x2 As Double, x3 As Double, x4 As Double, _ yi As Double, y1 As Double, y2 As Double, y3 As Double, y4 As Double) As Long If (Abs(xi - x1) < Abs(0.00001 * xi) And Abs(yi - y1) < Abs(0.00001 * yi)) Or _ (Abs(xi - x2) < Abs(0.00001 * xi) And Abs(yi - y2) < Abs(0.00001 * yi)) Then F = 1 ElseIf (Abs(x1 - x2) < (0.0000001 * x1) And (yi - y1) * (yi - y2) < 0) Or _ ((xi - x1) * (xi - x2) < 0) Then F = 2 Else Exit Function End If If Not (Abs(xi - x3) < Abs(0.00001 * xi) And Abs(yi - y3) < Abs(0.00001 * yi)) And _ Not (Abs(xi - x4) < Abs(0.00001 * xi) And Abs(yi - y4) < Abs(0.00001 * yi)) Then If Abs(x3 - x4) < Abs(0.000001 * yi) And Not ((yi - y3) * (yi - y4) < 0) Then Exit Function If Not (Abs(x3 - x4) < Abs(0.000001 * yi)) And Not ((xi - x3) * (xi - x4) < 0) Then Exit Function End If F = 1End Function

Sub Restructured() Dim xi As Double, x1 As Double, x2 As Double, x3 As Double, x4 As Double Dim yi As Double, y1 As Double, y2 As Double, y3 As Double, y4 As Double Dim F As Integer F = Abs((Abs(xi - x1) < Abs(0.00001 * xi) And Abs(yi - y1) < Abs(0.00001 * yi)) Or _ (Abs(xi - x2) < Abs(0.00001 * xi) And Abs(yi - y2) < Abs(0.00001 * yi))) If F = 0 Then If ((Abs(x1 - x2) < (0.0000001 * x1)) And _ ((yi - y1) * (yi - y2) < 0)) Or _ ((xi - x1) * (xi - x2) < 0) Then F = 2 End If If F Then If (Abs(xi - x3) < Abs(0.00001 * xi) And Abs(yi - y3) < Abs(0.00001 * yi)) Or _ (Abs(xi - x4) < Abs(0.00001 * xi) And Abs(yi - y4) < Abs(0.00001 * yi)) Then F = 1 End If If F = 2 Then If ((Abs(x3 - x4) < Abs(0.000001 * yi)) And _ ((yi - y3) * (yi - y4) < 0)) Or _ ((xi - x3) * (xi - x4) < 0) Then F = 1 End If End IfEnd Sub

I point out that the original code goes to some length to assign various values to F in its lower portion all of which are converted to =1 at line 30. This renders the jump to 30 unnecessary because the value =1 can be assigned immediately.

0

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

^ You are assuming that it is uninitialised when the code snippet commences.

If the jump to line 20 is valid during the successive tests, then setting F to 1 "immediately" (at the beginning of the code snippet) may be an inappropriate assumption.

That isn't what I am saying.
Since label 30 assigns F=1 and continues with label 20 any jump to label 30 can be replaced with the assignment F=1 followed by continuation at label 20.

Sorry for the confusion. I copied the code from the previous question and modified it. I forgot to delete the F=1 in after the label 30. I shall come back when I have tested the solutions. Apparently the first one seems good.

0

Featured Post

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210 (2 * 3 * 5 * 7) or 2310 (2 * 3 * 5 * 7 * 11).
The larger templa…