Thread: Aligning lists
View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Don Guillett[_4_] Don Guillett[_4_] is offline
external usenet poster
 
Posts: 2,337
Default Aligning lists

Oops, forgot the other columns so resize to one row and 2 columns.

Sub realign()
For Each c In Selection
If c.Offset(0, -1) < c Then c.Resize(1, 2).Insert shift:=xlDown
Next
End Sub
--
Don Guillett
SalesAid Software

"Richard" wrote in message
om...
Hello

I have been trying to get a macro to align lists for me but i am
having difficulty. The lists would look like this

col A B C D
b01 b01 DR1
b02 b02 DR5
b03 b04 DR6
b04 b05 DR2
b05 b06 DR33
b06 b08 DR54
b07
b08

Basically column A is outputted to a database which brings back the
columns B and C for any record where the value of field A is found. In
the example the identifier b03 is not in the database so nothing is
brought back and therefore the remaining records are shifted up. I
would like the data to end up as below

col A B C D
b01 b01 DR1
b02 b02 DR5
b03
b04 b04 DR6
b05 b05 DR2
b06 b06 DR33
b07
b08 b08 DR54

The only way i can do this is mannually using copy and paste, any
ideas how i can get a macro to do this?

Regards

Richard