Sort data in Excel with blank rows?

JohnnyBeGood

New Member
Joined
Mar 29, 2007
Messages
26
Office Version
  1. 365
Platform
  1. Windows
Hi all,

I've tried searching here and spent few hours trying myself but I cannot find solution how to sort when there's blank rows. It always removes spaces in between.
I need to sort column B along with text that is on the same row.
Any suggestions?

Not sorted:
1613186789183.png



Sorted:
1613186884720.png


TIA!
 

Excel Facts

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.
Do you want a manual solution or a VBA solution?
 
Upvote 0
Using the data you provided :
• Select B9 to B20
• Go to SpecialCells/Blanks
• Expand the selection by Ctrl + select B20
• Type =B9 and press Ctrl+Enter
• Select B9:D20 and sort by column B
• Select B9:B20 and go to SpecialCells/Formulas
• Clear contents

Here's a macro too :
VBA Code:
Sub v()
With Range("B9:B" & Cells(Rows.Count, 2).End(3)(2).Row)
    .SpecialCells(xlCellTypeBlanks).Formula = "=B9"
    .Resize(, 3).Sort Key1:=Range("B9"), Order1:=xlAscending, Header:=xlNo
    .SpecialCells(xlCellTypeFormulas).ClearContents
End With
End Sub
 
Upvote 0
Solution
I'm getting stuck on "Expand the selection by Ctrl + select B20" because once I do "SpecialCells/Blanks" B20 is already selected?

VBA Code works great!
 
Upvote 0
Looks like I'm doing it wrong. Once I do this step "Type =B9 and press Ctrl+Enter" I get below error. The purpose is to have all blank cells selected up to B20?

1613259962494.png
 
Upvote 0
The purpose is to select the blank cells in B9:B20 and then put a formula in each cell that returns the same value as the cell above.
 
Upvote 0

Forum statistics

Threads
1,214,980
Messages
6,122,563
Members
449,088
Latest member
Motoracer88

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