Sorting data between blank rows

Flexi1

New Member
Joined
Feb 15, 2015
Messages
15
Hi, this might be a really simple but for the life of me I cannot figure it out.

I have data between blank rows and I wish to sort the data between each blank rows A-Z.

So each section of data between the blank rows to be individually sorted A-Z and

BLANK ROW
DATA
DATA
DATA
BLANK ROW
DATA
DATA
DATA
BLANK ROW
 

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.
Assuming the data is in column A and that the data is not the result of formulas, try this with a copy of your data.

Code:
Sub SortAreas()
  Dim rng As Range
  
  For Each rng In Columns("A").SpecialCells(xlConstants).Areas
    rng.Sort Key1:=rng(1), Order1:=xlAscending, Header:=xlNo
  Next rng
End Sub
 
Upvote 0
Hi

This works however I would need the rest of the data across the cells to sort along with the data in column A

Many Thanks
 
Upvote 0
How about
Code:
Sub SortAreas()
  Dim rng As Range
  
  For Each rng In Columns("A").SpecialCells(xlConstants).Areas
    rng.CurrentRegion.Sort Key1:=rng(1), Order1:=xlAscending, Header:=xlNo
  Next rng
End Sub
 
Upvote 0
Hi

This worked to a point but there are gaps between columns in those blocks too.

Sorry I should have said.
 
Upvote 0
What is the last column of data?
 
Upvote 0
Hi

This works however I would need the rest of the data across the cells to sort along with the data in column A

Many Thanks
Add the red text to my previous code.
Rich (BB code):
rng.EntireRow.Sort Key1:=rng(1), Order1:=xlAscending, Header:=xlNo
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

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