hi all,

I m creating a macro that performs sorting.I m using quicksort algoritm.Its working fine for data below 5000 but as soon as data exceeds beyond it .
It shows Run-time error - 28 out of stack.
Is there any way to avoid too many recursion??
Please help me out...
below is code sample....
Sub RecursiveSort(ByVal llow As Long, ByVal lHigh As Long)
Dim lStart As Long
Dim lEnd As Long
Dim vTemp As Variant
Dim vPivot As Variant
lStart = lHigh
lEnd = llow
vPivot = a_vRowElements(lEnd)
'Till the count is less or equal to the max limit
Do While lEnd <= lStart

If bChkFlag = True Then
' While a_vRowElements(lEnd) < vPivot
While Compare(a_vRowElements(lEnd), vPivot)
lEnd = lEnd + 1
Wend
'While a_vRowElements(lStart) > vPivot
While Compare(vPivot, a_vRowElements(lStart))
lStart = lStart - 1
Wend
Else
'While a_vRowElements(lEnd) > vPivot
While Compare(vPivot, a_vRowElements(lEnd))
lEnd = lEnd + 1
Wend
'While a_vRowElements(lStart) < vPivot
While Compare(a_vRowElements(lStart), vPivot)
lStart = lStart - 1
Wend

End If
'
If lStart >= lEnd Then
If lStart <> lEnd Then
vTemp = a_vRowElements(lEnd)
a_vRowElements(lEnd) = a_vRowElements(lStart)
a_vRowElements(lStart) = vTemp
End If
lStart = lStart - 1
lEnd = lEnd + 1
End If
Loop
If llow <= lStart Then
RecursiveSort llow, lStart
End If
If lEnd < lHigh Then
RecursiveSort lEnd, lHigh
End If
End Sub