Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.word.tables
|
|||
|
|||
Table : how to mix the data in column 1 ?
Hi,
I have a table in Word 2002/XP I want to mix the data in column 1 ( alphabetic only with , and Is there a way to achieve that ? I do not want to sort but to mix randomly TIA !!! |
#2
Posted to microsoft.public.word.tables
|
|||
|
|||
Table : how to mix the data in column 1 ?
Running a macro containing the following code will sort the table in which
the selection is located in random order (assumes that row 1 is a header row and is not included in the sort Dim i As Long, j As Long Dim atable As Table Dim acol As Column Set atable = Selection.Tables(1) Set acol = atable.Columns.Add(BeforeColumn:=atable.Columns(1) ) i = atable.Rows.Count - 1 For j = 2 To i + 1 acol.Cells(j).Range.Text = (i * Rnd) + 1 Next atable.SortAscending atable.Columns(1).Delete -- Hope this helps. Please reply to the newsgroup unless you wish to avail yourself of my services on a paid consulting basis. Doug Robbins - Word MVP "MoiMeme" wrote in message ... Hi, I have a table in Word 2002/XP I want to mix the data in column 1 ( alphabetic only with , and Is there a way to achieve that ? I do not want to sort but to mix randomly TIA !!! |
#3
Posted to microsoft.public.word.tables
|
|||
|
|||
Table : how to mix the data in column 1 ?
Thanks a lot.
Works fine. But my tables that i want to mix up do not contain a header row. So I want row 1 mixed as well. Have tried to set j to 1 in the for j=2 to i+1, but that doesn't work. Row 1 still sticks to row 1. How should I proceed ? Many thanks ! That was fast and well done. "Doug Robbins - Word MVP" wrote: Running a macro containing the following code will sort the table in which the selection is located in random order (assumes that row 1 is a header row and is not included in the sort Dim i As Long, j As Long Dim atable As Table Dim acol As Column Set atable = Selection.Tables(1) Set acol = atable.Columns.Add(BeforeColumn:=atable.Columns(1) ) i = atable.Rows.Count - 1 For j = 2 To i + 1 acol.Cells(j).Range.Text = (i * Rnd) + 1 Next atable.SortAscending atable.Columns(1).Delete -- Hope this helps. Please reply to the newsgroup unless you wish to avail yourself of my services on a paid consulting basis. Doug Robbins - Word MVP "MoiMeme" wrote in message ... Hi, I have a table in Word 2002/XP I want to mix the data in column 1 ( alphabetic only with , and Is there a way to achieve that ? I do not want to sort but to mix randomly TIA !!! |
#4
Posted to microsoft.public.word.tables
|
|||
|
|||
Table : how to mix the data in column 1 ?
Hi,
have found out that I have to use Sort instead of SortAscending which excludes row 1 from sort. Now works as I wanted using simply aTable.Sort ( haven't used parameters since get error when trying, and default behaviour works fine) Thanks again for the hints ! "Phil" wrote: Thanks a lot. Works fine. But my tables that i want to mix up do not contain a header row. So I want row 1 mixed as well. Have tried to set j to 1 in the for j=2 to i+1, but that doesn't work. Row 1 still sticks to row 1. How should I proceed ? Many thanks ! That was fast and well done. "Doug Robbins - Word MVP" wrote: Running a macro containing the following code will sort the table in which the selection is located in random order (assumes that row 1 is a header row and is not included in the sort Dim i As Long, j As Long Dim atable As Table Dim acol As Column Set atable = Selection.Tables(1) Set acol = atable.Columns.Add(BeforeColumn:=atable.Columns(1) ) i = atable.Rows.Count - 1 For j = 2 To i + 1 acol.Cells(j).Range.Text = (i * Rnd) + 1 Next atable.SortAscending atable.Columns(1).Delete -- Hope this helps. Please reply to the newsgroup unless you wish to avail yourself of my services on a paid consulting basis. Doug Robbins - Word MVP "MoiMeme" wrote in message ... Hi, I have a table in Word 2002/XP I want to mix the data in column 1 ( alphabetic only with , and Is there a way to achieve that ? I do not want to sort but to mix randomly TIA !!! |
Reply |
Thread Tools | |
Display Modes | |
|
|