Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 195
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 104
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 195
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 195
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 195
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 104
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 195
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How do you append one row to another? BobVanS Excel Worksheet Functions 3 August 30th 07 02:04 PM
Find and append Susan Excel Discussion (Misc queries) 0 April 25th 07 08:08 PM
how to know which row to append for the last row tango Excel Programming 2 October 16th 04 02:23 PM
Qn: How to Append??? Michael Vaughan Excel Programming 1 September 19th 04 05:32 PM
append row Joe Excel Programming 4 July 30th 04 04:47 PM


All times are GMT +1. The time now is 05:28 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"