hsandeep
Well-known Member
- Joined
- Dec 6, 2008
- Messages
- 1,226
- Office Version
- 2010
- Platform
- Windows
- Mobile
I am using a Function findhigh as
In the code.
Then I am finding number of 1s in c Range using
Now the code works smoothly when
But the excel workbook gets hanged when
I am finishing the code with
What mistake is there in the code? Any revision/help so that hanging issue of the workbook gets solved will be highly appreciated.
Rich (BB code):
Function findhigh(a As Range, b As Range, c As Range) As String
In the code.
Then I am finding number of 1s in c Range using
Rich (BB code):
y = Application.CountIf(c, 1)
Rich (BB code):
If y >= 3 Then
If a(y) = 0 Or a(y) = "" Then GoTo finish
If b(y) = 0 Or b(y) = "" Then GoTo finish
Do While y > 1
hv = a(y): lv = b(y)
For q = y - 1 To 1 Step -1
If a(q) > hv And b(q) < lv Then
findhigh = Format(a(q), "0.00")
GoTo finish
End If
y = y - 1
Next q
Loop
End If
But the excel workbook gets hanged when
Rich (BB code):
If y = 2 Then
If a(y) = 0 Or a(y) = "" Then GoTo finish
If b(y) = 0 Or b(y) = "" Then GoTo finish
If a(y - 1) > a(y) And b(y - 1) < b(y) Then
findhigh = Format(a(y - 1), "0.00")
GoTo finish
End If
End If
I am finishing the code with
Rich (BB code):
findhigh = "null"
finish:
End With
End Function
What mistake is there in the code? Any revision/help so that hanging issue of the workbook gets solved will be highly appreciated.