Sorting

N

NaidyLady

I have a list in alphabetical order on an excel sheet.
I have a separate paragraph for each letter separated by a line.

E.g Bob
Boris

Carl
Catherine

How can I sort both the entire sheet and within the paragraphs together
rather than sorting each paragraph individually.
 
J

Joel

I would use a macro. Delete blank row, sort, then add blank row back

Sub sort()

'delete blank rows
LastRow = Range("A" & Rows.Count).End(xlUp).Row
For RowCount = LastRow To 1 Step -1
If Range("A" & RowCount) = "" Then
Rows(RowCount).Delete
End If
Next
'now sort
LastRow = Range("A" & Rows.Count).End(xlUp).Row
Set sortrange = Rows("1:" & LastRow)

sortrange.sort _
Key1:=Range("A4"), _
Order1:=xlAscending, _
Header:=xlGuess

'add blank row back
'delete blank rows
RowCount = 1
Do While Range("A" & RowCount) <> ""
If Left(Range("A" & RowCount), 1) <> _
Left(Range("A" & (RowCount + 1)), 1) Then

Rows(RowCount + 1).Insert
RowCount = RowCount + 1
End If

RowCount = RowCount + 1
Loop

End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top