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

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.
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,214,416
Messages
6,119,384
Members
448,889
Latest member
TS_711

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