添加新信息后,我正在尝试创建代码以对column A
中的范围进行排序。我已经尝试过此代码,但无法正常工作。
Private Sub Worksheet_Change(ByVal Target As Range)
On Error Resume Next
Range("A1").Sort Key1:=Range("A2"), _
Order1:=xlAscending, Header:=xlYes, _
OrderCustom:=1, MatchCase:=False, _
Orientation:=xlTopToBottom
End Sub
答案 0 :(得分:-1)
Private Sub Worksheet_Change(ByVal Target As Excel.Range)
Dim lastrow As Long
If Target.Column = 1 Then
lastrow = Cells(Rows.Count, 1).End(xlUp).ROW
Range("A2:A15" & lastrow).Sort key1:=Range("A2:A15" & lastrow), _
Order1:=xlAscending, Header:=xlNo
End If
End Sub