Private Sub返回ByRef参数types不匹配
我写了下面的函数
Public Function sorting(WS As Worksheets, Col As Range, Rng As Range, Sort_Order As XlSortOrder) Application.ScreenUpdating = False With WS .Sort.SortFields.Clear .Sort.SortFields.Add Key:=Col, SortOn:=xlSortOnValues, Order:=Sort_Order, DataOption:=xlSortNormal With .Sort .SetRange Rng .Header = xlYes .MatchCase = False .Orientation = xlTopToBottom .SortMethod = xlPinYin .Apply End With End With Application.ScreenUpdating = True End Function
现在我正在尝试基于该函数运行下面的代码。
Private Sub cmbCareerPath_Change() Application.ScreenUpdating = True Set WS = Worksheets("FindPath") Set Col = WS.Range("D:D") Set Rng = WS.Range("A:Z") Call sorting(WS, Col, Rng, xlAscending) Application.ScreenUpdating = False End Sub
但是,当我运行我的Sub我得到编译错误:
ByRef argument type mismatch
在下面的WS上。
调用sorting( WS ,Column,Rng,xlAscending)
任何帮助将不胜感激。
谢谢