Hello:
I wrote the following function
Now I am trying to run the following sub:
However, when I run my Sub I get the compile error:
on
. I am guessing is on WS, but I can't figure out why there would be a type mismatch.
Any ideas?
I wrote the following function
Code:
Public Function sorting(Sheets As Worksheet, Column As Range, Range As Range, SortOrder As XlSortOrder)
'This function is called when a sheet(s) needs to be sorted. Two procedures
'call on this function to sort.
'@Parameter Sheets to declare sheet(s) name
'@Parameter Column to set the column to sort
'@Parameter Range to set the range to sort
'@Paramenter SortOrder to determine ascending or descending
Application.ScreenUpdating = False
With Sheets
.Sort.SortFields.Clear
.Sort.SortFields.Add Key:=Column, SortOn:=xlSortOnValues, Order:=SortOrder, DataOption:=xlSortNormal
With .Sort
.SetRange Range
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
End With
Application.ScreenUpdating = True
End Function
Now I am trying to run the following sub:
Code:
Private Sub cmbCareerPath_Change()
Application.ScreenUpdating = True
Set WS = Worksheets("FindPath")
Set Column = WS.Range("D:D")
Set Rng = WS.Range("A:Z")
Call sorting(WS, Column, Rng, xlAscending)
Application.ScreenUpdating = False
End Sub
However, when I run my Sub I get the compile error:
Code:
ByRef argument type mismatch
Code:
Call sorting(WS, Column, Rng, xlAscending)
Any ideas?