Modification of Part Number (Revised)

T

Tiziano

I would like to add the string "1212" (no quotes) to some part numbers.

Essentially, I have two versions of part numbers to modify:
xxxxxxx(space)(space)xxxxxxxxxx(space)xxxxx(space)xxxx
or
xxxxxxxxxx(space)xxxxx(space)(space)xxxxxxx(space)xxxx(space)xxxx

The length of the xxxxxx strings varies and represents alphanumeric
characters that must remain unchanged. The string "1212" (no quotes) must
always be appended to the first xxxxx string of alphanumeric characters.

Thus the end result of the modification should be as follows:
xxxxxxx1212(space)(space)xxxxxxxxxx(space)xxxxx(space)xxxx
or
xxxxxxxxxx1212(space)xxxxx(space)(space)xxxxxxx(space)xxxx(space)xxxx

All the part numbers that I want to modify will be listed in Column A of my
spreadsheet. (There are other part numbers in other columns but I do not
want to modify them.)

Would somebody please suggest how to do it? This is beyond my knowledge of
Excel.

Thanks in advance.
 
E

Earl Kiosterud

Tiziano,

=LEFT(A2,FIND(" ",A2)-1)& "1212" &MID(A2,FIND(" ",A2),999)

Put this in another column, and copy down with the Fill Handle.
Paste-Special-Values over the original for a permanent change.
 
D

Don Guillett

I just re-tested this. Why doesn't it work for you?

Sub addnuminstr()
For Each c In Selection
X = InStr(c, " ") - 1
MsgBox Left(c, X) & 1212 & Right(c, Len(c) - X)
Next c
End Sub
 
T

Tiziano

You're right, Don, it works just right.
I guess I am not much used to running macros...
Thanks.
----
Tiziano

Don Guillett said:
I just re-tested this. Why doesn't it work for you?

Sub addnuminstr()
For Each c In Selection
X = InStr(c, " ") - 1
MsgBox Left(c, X) & 1212 & Right(c, Len(c) - X)
Next c
End Sub
 
T

Tiziano

Thanks, Earl!
It works just fine.
----
Tiziano

Earl Kiosterud said:
Tiziano,

=LEFT(A2,FIND(" ",A2)-1)& "1212" &MID(A2,FIND(" ",A2),999)

Put this in another column, and copy down with the Fill Handle.
Paste-Special-Values over the original for a permanent change.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top