How do I replace last numeric string from a alphanumeric string?

C

Christy

For example,
I want to replace "1055428" from CC03TW05040000010001055428 with "1162123",
so that my string would be CC03TW05040000010001162123.

Thanks!
 
Z

Zamdrist

Christy said:
For example,
I want to replace "1055428" from CC03TW05040000010001055428 with "1162123",
so that my string would be CC03TW05040000010001162123.

Thanks!

Is the last set of characters consistently 7 characters? If so...

sString = Left("CC03TW05040000010001055428",
Len("CC03TW05040000010001055428") -7) & "1162123"

"1162123" could be a variable or a field value too.

If it is not consistently 7 characters...maybe 1000 is? In which case
you could use the Mid function.

Steve
 
V

VBA Noob

Hi,

Say

A1 = CC03TW05040000010001055428
B1 = 1162123

then enter C1

=LEFT(A5,LEN(A5)-LEN(B5))&B5

VBA Noob
 
Top