Using Sort in Word or Excel

  surfer47 16:23 13 Jul 2008
Locked

I have created three columns in MS Word and I wish to sort them in alphabetical,that is to say Col 1 , Col 2 then Col three, order but the columns do not follow on from each other. I tried to Sort by column A then column B but while it sorted the A column, column B had sort very strange results. I h ave tried the same using Excel with the same result.Is there any way I can Sort so that the columns follow on.

  VoG II 16:39 13 Jul 2008

What do you mean by "follow on"?

Can you post a small sample of the unsorted data and the expected results?

  DieSse 16:57 13 Jul 2008

I'm not sure what you can and can't sort in Word - it may depend on using a table for the data.

But in Excel it's very easy - you have to mark the whole set of data to be sorted - then specify which column is to be used for the sorting.

If you don't mark the whole section, it will only sort one column - the other columns won't change.

If that's what you're getting at?

Perhaps VoG™ suggestion is best.

  hastelloy 18:12 13 Jul 2008

I don't think you can. If you want the whole list to be sorted it must be in one column and not split between multiple columns. -- Unless somebody knows better!!!!

  palinka 18:41 13 Jul 2008

I agree with marvin42 - what you SEEM to want to do is not possible in Word, and the only way is as marvin42 describes.
It's MUCH better to do it in Excel. I use it quite often for things like this - column 1- name; column 2- address; column3 - whatever.
You can make Excel sort that into a list by any of those columns (eg you can sort according to name; or according to address; etc)Highlight the whole lot, then type in that you want the sort order to be column 1,then column 2, then column 3. Or Column 2, then column 1; and so on, depending on what your list criterion is.

  PalaeoBill 21:17 13 Jul 2008

If I have understood this correctly....

What you need to do is create a table with 1 column and as many rows as you need.
Then select all of the rows (left click and drag) inside the table.
Then click on the columns icon (or Format menu option and select the columns option) and click on the 3 columns button.
Now you can load your data into the table and selecting sort, it will sort the data in order top to bottom such that the top of column 2 follows from the bottom of column 1, and the top of column 3 follows from the bottom of column 2.

  surfer47 19:35 15 Jul 2008

Thanks for all the input. What I am trying to do is to have a sheet divided into 2 columns, as the first column becomes full the list carries on in the second column. Having got 2 columns I would like to sort the lot alphabetically. I tried this in Excel without success, see below
Col 1 Col 2
a e
c g
d g
f h
v I
x j

This should then be a,c,d,e,f,g in the first column then g,h,i,j,v,w in the second.
Does that make sense?

  nosharpe 19:46 15 Jul 2008

Makes sense - you're trying to sort the characters from 2 columns as though they were in 1 column.

Is there a reason why you want this?

  VoG II 20:35 15 Jul 2008

As far as I know this is not possible using the native Sort function in Excel (or Word).

The following assumes that your data is in columns A and B with no header row.

Press ALT + F11 to open the Visual Basic Editor. Insert > Module and paste in:



Sub SpecialSort()
Dim LR1 As Integer, LR2 As Integer, j As Integer
Columns(3).Insert
LR1 = Range("A" & Rows.Count).End(xlUp).Row
LR2 = Range("A" & Rows.Count).End(xlUp).Row
j = LR1 + LR2
Range("A1:A" & LR1).Copy Destination:=Range("C1")
Range("B1:B" & LR2).Copy Destination:=Range("C" & LR1 + 1)
Application.CutCopyMode = False
Range("A1:A" & LR2).ClearContents
Range("B1:B" & LR2).ClearContents
Range("C1:C" & j).Sort Key1:=Range("C1"), Order1:=xlAscending, Header:=xlNo, Orientation:=xlTopToBottom
Range("A1:A" & LR1).Value = Range("C1:C" & LR1).Value
Range("B1:B" & LR2).Value = Range("C" & LR1 + 1 & ":C" & j).Value
Columns(3).Delete
End Sub


Close the VBE using the X then Tools > Macro > Macros, highlight SpecialSort and click the Run button.

  VoG II 20:36 15 Jul 2008

P.S. That is in Excel, not Word.

  VoG II 20:37 15 Jul 2008

Corrected code



Sub SpecialSort()
Dim LR1 As Integer, LR2 As Integer, j As Integer
Columns(3).Insert
LR1 = Range("A" & Rows.Count).End(xlUp).Row
LR2 = Range("B" & Rows.Count).End(xlUp).Row
j = LR1 + LR2
Range("A1:A" & LR1).Copy Destination:=Range("C1")
Range("B1:B" & LR2).Copy Destination:=Range("C" & LR1 + 1)
Application.CutCopyMode = False
Range("A1:A" & LR1).ClearContents
Range("B1:B" & LR2).ClearContents
Range("C1:C" & j).Sort Key1:=Range("C1"), Order1:=xlAscending, Header:=xlNo, Orientation:=xlTopToBottom
Range("A1:A" & LR1).Value = Range("C1:C" & LR1).Value
Range("B1:B" & LR2).Value = Range("C" & LR1 + 1 & ":C" & j).Value
Columns(3).Delete
End Sub

This thread is now locked and can not be replied to.

Elsewhere on IDG sites

OnePlus 5 review

See the work of famous artists playing with toys

iPad Pro 10.5in (2017) review

Comment faire une capture d’écran sur un Mac ?