0
Excel VBA:我想动态获取最后一列字符并将其作为最后一列传递,同时选择排序范围。但它似乎并没有在这里工作是代码动态获取最后一列字符并将其传递
Sub Sort_THAT_IS_NOT_CALLED_SORT_BECAUSE_THAT_IS_A_RESEVED_WORD()
Dim lastrowcheck As Long, n1 As Long, LastRowcheck1 As Long, n2 As Long
Dim lcol As Integer, colletter As String
With Worksheets("MergeSheet")
lastrowcheck = .Range("A" & .Rows.Count).End(xlUp).Row
For n1 = 2 To lastrowcheck
If .Cells(n1, 1).Value = "FUND" Then
.Rows(n1).Delete
End If
Next n1
ActiveWorkbook.Worksheets("MergeSheet").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("MergeSheet").Sort.SortFields.Add Key:=Range(_
"A2"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _
xlSortNormal
With ActiveWorkbook.Worksheets("MergeSheet").Sort
lcol = Cells(1, Columns.Count).End(xlToLeft).Column
colletter = ConvertToLetter(lcol)
.SetRange Range("A2:colletter" & lastrowcheck)
.Header = xlNo
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
End With
End Sub
您的代码表明您没有标题行,但您从第2行开始。您能否确认没有标题行? – Jeeped