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