Question : Macro to Sort by Column and Delete Blanks


I am trying to sort "ascending" by column C. and once it is sorted, go to the last row in C and delete all the  rows below it.
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
Sub A1_SortbyAcctandDeleteBlanks()

    Range("A1").Select
    Selection.Sort Key1:=Range("C2"), Order1:=xlAscending, Header:=xlGuess, _
        OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
    Range("C1").Select
    Selection.End(xlDown).Select
    ActiveCell.Offset(1, 0).EntireRow.Select
    ActiveCell.Offset(1, 0).Range("A1").Activate
    Selection.Clear
    Range("A1").Select
End Sub

Answer : Macro to Sort by Column and Delete Blanks

Try this code
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
Sub removextras()
Dim lastc As Long
Dim lastrow As Long
lastc = Range("C" & Rows.Count).End(xlUp).Row
lastrow = ActiveSheet.UsedRange.Rows.Count
If lastc <> lastrow Then
Rows(lastc + 1 & ":" & lastrow).Delete
Else
End If
End Sub
Random Solutions  
 
programming4us programming4us