Replace Alpha with Numeric Character

Gos-C

Active Member
Joined
Apr 11, 2005
Messages
258
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
Hi all,

Each cells in a column E range contains a 15-character numeric or alphanumeric string - e.g., 000000123456789, 000000000F16520, 000000TEST12345 and 000000000123XY9. I have to add a number to the cell value and then multiply it by another number. Therefore, I need to replace all alpha with numeric characters. I am having difficulty writing the code. Here is what I have:

Code:
Sub ReplaceAlpha()
Dim rCell As Range
Dim lLR As Long
lLR = Cells(Rows.Count, "E").End(xlUp).Row
For Each rCell In Range("E2:E" & lLR)
rCell = Search(rCell, "a", 1)
rCell = Search(rCell, "b", 2)
rCell = Search(rCell, "c", 3)
rCell = Search(rCell, "d", 4)
rCell = Search(rCell, "e", 5)
rCell = Search(rCell, "f", 6)
rCell = Search(rCell, "g", 7)
rCell = Search(rCell, "h", 8)
rCell = Search(rCell, "i", 9)
rCell = Search(rCell, "j", 1)
rCell = Search(rCell, "k", 2)
rCell = Search(rCell, "l", 3)
rCell = Search(rCell, "m", 4)
rCell = Search(rCell, "n", 5)
rCell = Search(rCell, "o", 6)
rCell = Search(rCell, "p", 7)
rCell = Search(rCell, "q", 8)
rCell = Search(rCell, "r", 9)
rCell = Search(rCell, "s", 1)
rCell = Search(rCell, "t", 2)
rCell = Search(rCell, "u", 3)
rCell = Search(rCell, "v", 4)
rCell = Search(rCell, "w", 5)
rCell = Search(rCell, "x", 6)
rCell = Search(rCell, "y", 7)
rCell = Search(rCell, "z", 8)
End Sub

Can someone help me, please.

Thank you,
Gos-C
 
Hi mikerickson,

Thank you very much for the explanation.

I modified the macro as follows:

Code:
Sub test()
    Dim oneCell As Range
    For Each oneCell In Range("E2", Range("E" & Rows.Count).End(xlUp))
        oneCell.Offset(0, 1).Value = (AlphaToNum(CStr(oneCell.Value)) + 678678) * 12
    Next oneCell
End Sub

How do I modify it further to format it back to a 15-character string?

Thanks,
Gos-C
 
Upvote 0

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.
Hi mikerickson,

I can't get it to work. Can you please give me the exact code.

Thank you,
Gos-C
 
Upvote 0

Forum statistics

Threads
1,224,586
Messages
6,179,730
Members
452,939
Latest member
WCrawford

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top