Tocogroup
asked on
How do I call a function within a VBA procedure ?
Hi Experts,
I am creating a VBA procedure within my Excel 2010 application in which I need to sort a 2-dimensional array.
Having scoured the Web I seem to have found a more robust VBA code example of a Sort function. However, not having ever used functions before, the function is falling over at the first stage, that is, it gives me compilation errors.
This is the code within my procedure:
Dim ClientsArray() As Variant
Dim InputArray() As Variant
' Load Clients array from Clients sheet (B3:L).........This works fine !
ClientsArray() = Range(Sheets("Clients").Ce lls(3, 2), Sheets("Clients").Cells(Sh eets("Clie nts").Cell s(3, 1).End(xlDown), 12)).Value
InputArray = ClientsArray()
'Sort the array by Name (2nd column) ascending........This doesn't work !
ClientsArray() = QSortInPlace( _
ByRef InputArray As Variant, _
Optional ByVal LB As Long = -1&, _
Optional ByVal UB As Long = -1&, _
Optional ByVal Descending As Boolean = False, _
Optional ByVal CompareMode As VbCompareMethod = vbTextCompare, _
Optional ByVal NoAlerts As Boolean = False) As Boolean
The above piece of code is obviously wrong as it highlights in red but I can't seem to get the syntax right. I've attached the called function code in a text file.
Any help will be appreciated.
Toco
Sort-Function-VBA-code.txt
I am creating a VBA procedure within my Excel 2010 application in which I need to sort a 2-dimensional array.
Having scoured the Web I seem to have found a more robust VBA code example of a Sort function. However, not having ever used functions before, the function is falling over at the first stage, that is, it gives me compilation errors.
This is the code within my procedure:
Dim ClientsArray() As Variant
Dim InputArray() As Variant
' Load Clients array from Clients sheet (B3:L).........This works fine !
ClientsArray() = Range(Sheets("Clients").Ce
InputArray = ClientsArray()
'Sort the array by Name (2nd column) ascending........This doesn't work !
ClientsArray() = QSortInPlace( _
ByRef InputArray As Variant, _
Optional ByVal LB As Long = -1&, _
Optional ByVal UB As Long = -1&, _
Optional ByVal Descending As Boolean = False, _
Optional ByVal CompareMode As VbCompareMethod = vbTextCompare, _
Optional ByVal NoAlerts As Boolean = False) As Boolean
The above piece of code is obviously wrong as it highlights in red but I can't seem to get the syntax right. I've attached the called function code in a text file.
Any help will be appreciated.
Toco
Sort-Function-VBA-code.txt
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Back to the drawing board.
Thanks again
Toco