1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
| Sub test()
Dim i As Integer
Dim DerLig As Long
Dim Cel As Range
Dim Ws As Worksheet
Set Ws = ActiveSheet
With Ws
DerLig = .Range("J" & .Rows.Count).End(xlUp).Row
.Sort.SortFields.Clear
.Sort.SortFields.Add Key:=.Range("J1:J" & DerLig), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _
xlSortNormal
With .Sort
.SetRange Ws.Range("A1:Z" & DerLig)
.Header = xlGuess
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
For Each Cel In .Range("J1:J" & DerLig)
If Cel.Value = "C" Then
Cel.Offset(0, 1).Cut Cel.Offset(0, 2)
Else
Cel.Offset(0, 2) = ""
End If
Next
.Range("J1").EntireColumn.Delete
End With
End Sub |