Aligning lists
Richard,
if both columns A & B are returned in sequential order,
then something like this (untested) code should work:
Sub ReAlign()
Dim LastRow as integer
Dim X as Integer
LastRow = ActiveSheet.UsedRange.Row - 1 + _
ActiveSheet.UsedRange.Rows.Count
For X=1 to lastrow
If cells(x,2).value < cells(x,1).value) then
range(cells(x,2),cells(Lastrow,3)).cut destination:= _
Cells(X+1,2)
End if
Next X
End Sub
'Cheers, Pete.
-----Original Message-----
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
.
|