Macro - sorting column

PurrSent

Board Regular
Joined
Jun 7, 2014
Messages
136
I have a macro that I'm running which sorts column 'C' (contents are surnames) into alphabetical order, including keeping the data in the same row with the sorted name. for instance, Column B is Date, Column C is name, D, E, F - AB etc has data related to the Name and Date in B and C

Question:
When I use the macro to 'Sort Name' alphabetically, the data is sorted but there are a number of empty rows left above the sorted data, without any data in other columns of the same row.

Is there any way these blank rows can be at the bottom of the list?

The contents of column C 'Name' contains a formula to bring the name forward from the previous month, ie Formula in cells -> =IF(Aug!C128=0,"",Aug!C128)

Might the empty rows being placed at the top of the column be because of formular / data brought forward from the previous month, perhaps?

I appreciate any help with this issue. Many thanks
PurrSent %

Macro being used to 'Sort Name'
VBA Code:
Sub SortName()
'
' Sort Name Column 'C' - A-Z



    ActiveSheet.Unprotect
 '   Range("B24").Select
 '   ActiveWindow.SmallScroll Down:=50
    Range("B24:AB218").Select
    ActiveSheet.Sort.SortFields.Clear
    ActiveSheet.Sort.SortFields.Add Key:=Range("C24:C218"), _
        SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
    With ActiveSheet.Sort
        .SetRange Range("B24:AB218")
        .Header = xlGuess
        .MatchCase = False
        .Orientation = xlTopToBottom
        .SortMethod = xlPinYin
        .Apply
    End With

    ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True
    Range("C26").Select
End Sub
 

Excel Facts

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.

Forum statistics

Threads
1,214,877
Messages
6,122,051
Members
449,064
Latest member
scottdog129

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top