View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
bj bj is offline
external usenet poster
 
Posts: 1,397
Default Can Excel Do This For Me????

if the data is alread sorted like your sample
a brute force method would be something like

sub srt()
r = 1
10 if cells(r,1 = "" and cells(r,2) = "" then 99
if cells(r,1)=cells(r,2) then r=r+1: goto 10
if cells(r,1)<cells(r,2) then
cells(r,2).select
Selection.Insert Shift:=xlDown
else
cells(r,1).select
Selection.Insert Shift:=xlDown
end if
r=r+1: goto 10
99
end sub


If you will be doing this a bunch it is worthwhile to use the option
explicit and dimension all of the variables
If you need to sort the data that could be added.



"Sean" wrote:

I have a daily spreadsheet that I drop data into and then go through and sort
through it like so. Please see examples:

RAW DATA BEFORE I DO WHAT I DO TO IT. OR HOPEFULLY EXCEL CAN

Column A Column B
514-212 514-212
514-222 82Q-1A
600QR-NC-D CC4545
6905-213 FB2130-O
6905-223 FB2741-O
82Q-1A FB3648-O
B0081CK-1 FB4430-O
FB2130-O FB4860-O
FB2272-O GFD9400S-B
FB2725-O GS9013-M

THIS IS WHAT THE FINISHED EFFECT LOOKS LIKE AFTER I FINISH!!!

514-212 514-212
514-222
600QR-NC-D
6905-213
6905-223
82Q-1A 82Q-1A
B0081CK-1
CC4545
FB2130-O FB2130-O
FB2272-O
FB2741-O
FB2725-O
FB3648-O
FB4430-O
FB4860-O
GFD9400S-B
GS9013-M

As you can see I go through and move the cells down to match up like items
and leave unlike items by themselves in an numeric to alphabetic order. My
question is Can I write a macro or a formula that does this for me????

Thanks in advance...