IN EXCEL, HOW DO I KEEP TWO LINES OF DATA TOGETHER WHEN SORTING (N

  • Thread starter Thread starter Cheryl
  • Start date Start date
C

Cheryl

In a data base, I have customer information and blank lines in between to
separate the data. I want to keep the blank lines under the customer
information to make the data base easier to read, how do I do this?
 
One easy way - if there are not too many entries - is to repeat the entry in
the sort column on the blank line in white text.
Ron
 
Cheryl
This little macro will do that. As written, this macro sorts all data
from A2 down to the last entry in Column A, 7 columns wide. This will
remove all blank rows. This macro will then insert blank rows like you
want. Another way to get what you want, i.e. easier to read, is to have no
blank rows but color alternate rows. HTH Otto
Sub SortAll()
Dim rColA As Range
Dim c As Long
Set rColA = Range("A2", Range("A" & Rows.Count).End(xlUp))
rColA.Resize(, 7).Sort Key1:=Range("A2"), Order1:=xlAscending,
Header:=xlNo, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
Set rColA = Range("A2", Range("A" & Rows.Count).End(xlUp))
For c = rColA.Count To 1 Step -1
rColA(c).Offset(1).EntireRow.Insert
Next c
End Sub
 
Get rid of the blank lines and simply set the rows to double height.


Gord Dibben MS Excel MVP
 
Back
Top