Vba 创建排序时类型不匹配
我不断发现以下代码的类型不匹配,尤其是Vba 创建排序时类型不匹配,vba,excel,sorting,Vba,Excel,Sorting,我不断发现以下代码的类型不匹配,尤其是SortFields.Add行。我想知道是什么导致了这个问题?谢谢 worksheet.select With worksheet.Sort .SortFields.Clear .SortFields.Add(Rng, xlSortOnCellColor, xlAscending, , xlSortNormal). _ SortOnValu
SortFields.Add
行。我想知道是什么导致了这个问题?谢谢
worksheet.select
With worksheet.Sort
.SortFields.Clear
.SortFields.Add(Rng, xlSortOnCellColor, xlAscending, , xlSortNormal). _
SortOnValue.Color = RGB(255, 255, 0)
.SetRange = consolidated_sheet.Range("A3:K" & row)
.Header = xlNo
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
也许你在追求这个:
With worksheet.Sort
.SortFields.Clear
.SortFields.Add rng, xlSortOnCellColor, xlAscending, , xlSortNormal
.SortOnValue.Color = RGB(255, 255, 0)
.SetRange consolidated_sheet.Range("A3:K" & row)
.Header = xlNo
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
在代码中,您有:
- 包含SortFields.Add()方法参数的不需要的括号
- 在延续线之前的点,而不是相反的点
- 已将rng声明为有效的
参考范围
Rng
?