R
Ron Rosenfeld
Hi all,
how do separate alpha numeric value for example I have values like
ABC123,AB234
starts with alpha but the length may be 2 or 3 or 4. just I want alpha value
in one column and numeric in another column.
could anyone help me ?
thanks
This Macro will split "selection" into letters and digits in the adjacent
columns.
You can hard-code "selection" to a given range, or set up the range to step
through in various ways.
To enter it, <alt-F11> opens the VB Editor. Ensure your project is highlighted
in the project explorer window, then Insert/Module and paste the code below
into the window that opens.
To use it, select your range, then <alt-F8> and run the Macro.
========================================
Option Explicit
Sub reExtr()
Dim c As Range
Dim re As Object
Set re = CreateObject("vbscript.regexp")
re.Global = True
For Each c In Selection
re.Pattern = "[^A-Za-z]"
c.Offset(0, 1).Value = re.Replace(c.Value, "")
re.Pattern = "\D"
c.Offset(0, 2).Value = re.Replace(c.Value, "")
Next c
End Sub
========================================
--ron