Private Sub CommandButton1_Click()
Dim C&, i&
C = Cells(1, Columns.Count).End(xlToLeft).Column + 1
For i = 1 To 3: Cells(i, C) = UserForm1("TextBox" & i): Next
Range([B1], Cells(3, C)).Sort Key1:=[B1], Order1:=xlAscending, Header:=xlNo, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlLeftToRight
End Sub作者: owen06 時間: 2015-11-4 13:03
Private Sub CommandButton1_Click()
Dim C&, i&
With Sheets("Sheet1")
C = .Cells(1, Columns.Count).End(xlToLeft).Column + 1
For i = 1 To 3: .Cells(i, C) = UserForm1("TextBox" & i): Next
Range(.[B1], .Cells(3, C)).Sort Key1:=.[B1], Order1:=xlAscending, Header:=xlNo, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlLeftToRight
End With
End Sub
Sub TEST()
Dim C&
With Sheets("工作表2")
C = .Cells(10, Columns.Count).End(xlToLeft).Column + 1
Range(.[C10], .Cells(15, C)).Sort Key1:=.[C10], Order1:=xlAscending, Header:=xlNo, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlLeftToRight
End With
End Sub