Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
What can I append
I have a workbook laid out in such a way that this will append numbers to
dummy names the way I want: Sub AppendNumber() c = 36 For i = ActiveSheet.UsedRange.Rows.Count - 14 To 3 Step -15 Range("A" & i).Value = "LASTNAME" & c & ", " & "FIRSTNAME" c = c - 1 Next End Sub Problem is that another routine that ends up sorting my range Ascending screws up the numeric order of the appended numbers, ex: last name in the sorted list winds up as LASTNAME9, FIRSTNAME Is there something else I can append to the names that will allow a proper sort? -- David |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
What can I append
David,
You could try names in the format: 39LASTNAME,FIRSTNAME. A sort ascending would keep your numbers sequential. Another way is to use a hidden column with just the numbers in and sort your range on that column. E.g. A1 = Lastname56,Firstname and X1 = 56. Sort on column X Henry "David" wrote in message ... I have a workbook laid out in such a way that this will append numbers to dummy names the way I want: Sub AppendNumber() c = 36 For i = ActiveSheet.UsedRange.Rows.Count - 14 To 3 Step -15 Range("A" & i).Value = "LASTNAME" & c & ", " & "FIRSTNAME" c = c - 1 Next End Sub Problem is that another routine that ends up sorting my range Ascending screws up the numeric order of the appended numbers, ex: last name in the sorted list winds up as LASTNAME9, FIRSTNAME Is there something else I can append to the names that will allow a proper sort? -- David |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
What can I append
Henry wrote
You could try names in the format: 39LASTNAME,FIRSTNAME. A sort ascending would keep your numbers sequential. Think I'll go this route Another way is to use a hidden column with just the numbers in and sort your range on that column. E.g. A1 = Lastname56,Firstname and X1 = 56. Sort on column X There already is a hidden helper column I sort on. These dummy names are ultimately going to be replaced by the user with real names, and formulas already in hidden helper column are an integral part of the sort routine. -- David |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
What can I append
Henry wrote
You could try names in the format: 39LASTNAME,FIRSTNAME. A sort ascending would keep your numbers sequential. Well, since my helper column strips off ', FIRSTNAME', subsequent resort produced: 10LASTNAME, FIRSTNAME 11LASTNAME, FIRSTNAME 12LASTNAME, FIRSTNAME 13LASTNAME, FIRSTNAME 14LASTNAME, FIRSTNAME 15LASTNAME, FIRSTNAME 16LASTNAME, FIRSTNAME 17LASTNAME, FIRSTNAME 18LASTNAME, FIRSTNAME 19LASTNAME, FIRSTNAME 1LASTNAME, FIRSTNAME 20LASTNAME, FIRSTNAME 21LASTNAME, FIRSTNAME 22LASTNAME, FIRSTNAME 23LASTNAME, FIRSTNAME 24LASTNAME, FIRSTNAME 25LASTNAME, FIRSTNAME 26LASTNAME, FIRSTNAME 27LASTNAME, FIRSTNAME 28LASTNAME, FIRSTNAME 29LASTNAME, FIRSTNAME 2LASTNAME, FIRSTNAME 30LASTNAME, FIRSTNAME 31LASTNAME, FIRSTNAME 32LASTNAME, FIRSTNAME 33LASTNAME, FIRSTNAME 34LASTNAME, FIRSTNAME 35LASTNAME, FIRSTNAME 36LASTNAME, FIRSTNAME 3LASTNAME, FIRSTNAME 4LASTNAME, FIRSTNAME 5LASTNAME, FIRSTNAME 6LASTNAME, FIRSTNAME 7LASTNAME, FIRSTNAME 8LASTNAME, FIRSTNAME 9LASTNAME, FIRSTNAME Rats!! -- David |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
What can I append
David wrote
Sub AppendNumber() c = 36 For i = ActiveSheet.UsedRange.Rows.Count - 14 To 3 Step -15 Range("A" & i).Value = "LASTNAME" & c & ", " & "FIRSTNAME" c = c - 1 Next End Sub For my fortunately limited range (this is only a one time deal), this works: Sub AppendNumber() c = 90 For i = ActiveSheet.UsedRange.Rows.Count - 14 To 3 Step -15 Range("A" & i).Value = "LASTNAME" & Chr(c) & ", " & "FIRSTNAME" If c = 65 Then c = c - 7 c = c - 1 Next End Sub -- David |
#6
Posted to microsoft.public.excel.programming
|
|||
|
|||
What can I append
David,
Range("A" & i).Value = c & "LASTNAME" & ", " & "FIRSTNAME" If C<10 then Range("A" & i). Value = "0" & Range("A" & i). Value will give you 01xxx, 02xxx, etc. which will sort properly. Henry "David" wrote in message ... Henry wrote You could try names in the format: 39LASTNAME,FIRSTNAME. A sort ascending would keep your numbers sequential. Well, since my helper column strips off ', FIRSTNAME', subsequent resort produced: 10LASTNAME, FIRSTNAME 11LASTNAME, FIRSTNAME 12LASTNAME, FIRSTNAME 13LASTNAME, FIRSTNAME 14LASTNAME, FIRSTNAME 15LASTNAME, FIRSTNAME 16LASTNAME, FIRSTNAME 17LASTNAME, FIRSTNAME 18LASTNAME, FIRSTNAME 19LASTNAME, FIRSTNAME 1LASTNAME, FIRSTNAME 20LASTNAME, FIRSTNAME 21LASTNAME, FIRSTNAME 22LASTNAME, FIRSTNAME 23LASTNAME, FIRSTNAME 24LASTNAME, FIRSTNAME 25LASTNAME, FIRSTNAME 26LASTNAME, FIRSTNAME 27LASTNAME, FIRSTNAME 28LASTNAME, FIRSTNAME 29LASTNAME, FIRSTNAME 2LASTNAME, FIRSTNAME 30LASTNAME, FIRSTNAME 31LASTNAME, FIRSTNAME 32LASTNAME, FIRSTNAME 33LASTNAME, FIRSTNAME 34LASTNAME, FIRSTNAME 35LASTNAME, FIRSTNAME 36LASTNAME, FIRSTNAME 3LASTNAME, FIRSTNAME 4LASTNAME, FIRSTNAME 5LASTNAME, FIRSTNAME 6LASTNAME, FIRSTNAME 7LASTNAME, FIRSTNAME 8LASTNAME, FIRSTNAME 9LASTNAME, FIRSTNAME Rats!! -- David |
#7
Posted to microsoft.public.excel.programming
|
|||
|
|||
What can I append
Henry wrote
Range("A" & i).Value = c & "LASTNAME" & ", " & "FIRSTNAME" If C<10 then Range("A" & i). Value = "0" & Range("A" & i). Value will give you 01xxx, 02xxx, etc. which will sort properly. Thanks. I adapted that concept to append to end of "LASTNAME" rather than the beginning and now I'm happy. I was just about to initialize C to 99 and live with that when I saw your post. -- David |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
How do you append one row to another? | Excel Worksheet Functions | |||
Find and append | Excel Discussion (Misc queries) | |||
how to know which row to append for the last row | Excel Programming | |||
Qn: How to Append??? | Excel Programming | |||
append row | Excel Programming |