Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 64
Default Macro to re-number data




I have a spread sheet that could be a few hundred rows or 50000 plus
row of data. In the first column is a 38 character (letters and
numbers) data string. But in that string there is a six digit sequence
number. The numbers always run consecutively. The first cell A1 could
start a 000001 or 014235 or any six digit number including leading
zeros. The sequence number starts at character 9 - 14. I'm trying to
create a macro that will resequence the characters (9-14) staring from
a sequence number I chose. For example"

The first sequene number below is 010926 thru 010932
A
1 ABCDASAY01092600040004000000000000XXXX
2 ABCDASAY01092700040004000000000000XXXX
3 ABCDASAY01092800040004000000000000XXXX
4 ABCDASAY01092900040004000000000000XXXX
5 ABCDASAY01093000040004000000000000XXXX
6 ABCDASAY01093100040004000000000000XXXX
7 ABCDASAY01093200040004000000000000XXXX


f I wanted to resequence column at starting at 004421 the macro would
return this



A
1 ABCDASAY00442100040004000000000000XXXX
2 ABCDASAY00442200040004000000000000XXXX
3 ABCDASAY00442300040004000000000000XXXX
4 ABCDASAY00442400040004000000000000XXXX
5 ABCDASAY00442500040004000000000000XXXX
6 ABCDASAY00442600040004000000000000XXXX
7 ABCDASAY00442700040004000000000000XXXX





Thanks
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Macro to re-number data

Maybe you could use a formula like:
="ABCDASAY"&text(row()+1,"000000")&"00040004000000 000000XXXX"
(starting in row 1)

or
=left(a1,8)&text(row()+1,"000000")&mid(a1,15,255)
in B1

Then drag the formula down as far as you need.
And then convert the formulas to values (edit|Copy, edit|Paste special|values).

Little Penny wrote:

I have a spread sheet that could be a few hundred rows or 50000 plus
row of data. In the first column is a 38 character (letters and
numbers) data string. But in that string there is a six digit sequence
number. The numbers always run consecutively. The first cell A1 could
start a 000001 or 014235 or any six digit number including leading
zeros. The sequence number starts at character 9 - 14. I'm trying to
create a macro that will resequence the characters (9-14) staring from
a sequence number I chose. For example"

The first sequene number below is 010926 thru 010932
A
1 ABCDASAY01092600040004000000000000XXXX
2 ABCDASAY01092700040004000000000000XXXX
3 ABCDASAY01092800040004000000000000XXXX
4 ABCDASAY01092900040004000000000000XXXX
5 ABCDASAY01093000040004000000000000XXXX
6 ABCDASAY01093100040004000000000000XXXX
7 ABCDASAY01093200040004000000000000XXXX

f I wanted to resequence column at starting at 004421 the macro would
return this

A
1 ABCDASAY00442100040004000000000000XXXX
2 ABCDASAY00442200040004000000000000XXXX
3 ABCDASAY00442300040004000000000000XXXX
4 ABCDASAY00442400040004000000000000XXXX
5 ABCDASAY00442500040004000000000000XXXX
6 ABCDASAY00442600040004000000000000XXXX
7 ABCDASAY00442700040004000000000000XXXX

Thanks


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default Macro to re-number data

That did Joel.


Thank you Thank you Thank you.


Sub resequence()
Dim SequenceCount
Dim RowCount
Dim Prefix
Dim Suffix
Dim SequenceString

SequenceCount = _
Val(InputBox("Enter Start Sequence Number"))
RowCount = 1
Do While Cells(RowCount, "A") < ""
Prefix = Left(Cells(RowCount, "A").Value, 8)
Suffix = Mid(Cells(RowCount, "A").Value, 15)
SequenceString = _
Format(SequenceCount, "0#####")
Cells(RowCount, "B") = Prefix & _
SequenceString & Suffix
SequenceCount = SequenceCount + 1
RowCount = RowCount + 1
Loop
End Sub
"Little Penny" wrote:




I have a spread sheet that could be a few hundred rows or 50000 plus
row of data. In the first column is a 38 character (letters and
numbers) data string. But in that string there is a six digit sequence
number. The numbers always run consecutively. The first cell A1 could
start a 000001 or 014235 or any six digit number including leading
zeros. The sequence number starts at character 9 - 14. I'm trying to
create a macro that will resequence the characters (9-14) staring from
a sequence number I chose. For example"

The first sequene number below is 010926 thru 010932
A
1 ABCDASAY01092600040004000000000000XXXX
2 ABCDASAY01092700040004000000000000XXXX
3 ABCDASAY01092800040004000000000000XXXX
4 ABCDASAY01092900040004000000000000XXXX
5 ABCDASAY01093000040004000000000000XXXX
6 ABCDASAY01093100040004000000000000XXXX
7 ABCDASAY01093200040004000000000000XXXX


f I wanted to resequence column at starting at 004421 the macro would
return this



A
1 ABCDASAY00442100040004000000000000XXXX
2 ABCDASAY00442200040004000000000000XXXX
3 ABCDASAY00442300040004000000000000XXXX
4 ABCDASAY00442400040004000000000000XXXX
5 ABCDASAY00442500040004000000000000XXXX
6 ABCDASAY00442600040004000000000000XXXX
7 ABCDASAY00442700040004000000000000XXXX





Thanks

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 64
Default Macro to re-number data


Thanks again Joel

That did it................


One day I hope i'm as good as you with this stuff.

But i'm learning


Thanks








On Fri, 7 Sep 2007 19:18:02 -0700, Joel
wrote:

That did Joel.


Thank you Thank you Thank you.


Sub resequence()
Dim SequenceCount
Dim RowCount
Dim Prefix
Dim Suffix
Dim SequenceString

SequenceCount = _
Val(InputBox("Enter Start Sequence Number"))
RowCount = 1
Do While Cells(RowCount, "A") < ""
Prefix = Left(Cells(RowCount, "A").Value, 8)
Suffix = Mid(Cells(RowCount, "A").Value, 15)
SequenceString = _
Format(SequenceCount, "0#####")
Cells(RowCount, "B") = Prefix & _
SequenceString & Suffix
SequenceCount = SequenceCount + 1
RowCount = RowCount + 1
Loop
End Sub
"Little Penny" wrote:




I have a spread sheet that could be a few hundred rows or 50000 plus
row of data. In the first column is a 38 character (letters and
numbers) data string. But in that string there is a six digit sequence
number. The numbers always run consecutively. The first cell A1 could
start a 000001 or 014235 or any six digit number including leading
zeros. The sequence number starts at character 9 - 14. I'm trying to
create a macro that will resequence the characters (9-14) staring from
a sequence number I chose. For example"

The first sequene number below is 010926 thru 010932
A
1 ABCDASAY01092600040004000000000000XXXX
2 ABCDASAY01092700040004000000000000XXXX
3 ABCDASAY01092800040004000000000000XXXX
4 ABCDASAY01092900040004000000000000XXXX
5 ABCDASAY01093000040004000000000000XXXX
6 ABCDASAY01093100040004000000000000XXXX
7 ABCDASAY01093200040004000000000000XXXX


f I wanted to resequence column at starting at 004421 the macro would
return this



A
1 ABCDASAY00442100040004000000000000XXXX
2 ABCDASAY00442200040004000000000000XXXX
3 ABCDASAY00442300040004000000000000XXXX
4 ABCDASAY00442400040004000000000000XXXX
5 ABCDASAY00442500040004000000000000XXXX
6 ABCDASAY00442600040004000000000000XXXX
7 ABCDASAY00442700040004000000000000XXXX





Thanks

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
Creating number formula to count number occurences in a data set Brreese24 Excel Programming 1 August 23rd 07 11:18 PM
Convert a number formatted as text to a number in a macro MACRE0[_5_] Excel Programming 2 October 22nd 05 02:51 AM
macro adding a number to a number already in a cell Tom Ogilvy Excel Programming 0 October 18th 03 04:34 PM
macro adding a number to a number already in a cell Don Guillett[_4_] Excel Programming 0 October 17th 03 05:21 PM
macro adding a number to a number already in a cell Ron de Bruin Excel Programming 0 October 17th 03 04:59 PM


All times are GMT +1. The time now is 08:42 PM.

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"