View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.misc
Mike H Mike H is offline
external usenet poster
 
Posts: 11,501
Default Move selected Text/Numbers from Col D to Col A/B

Maybe this

Right click your sheet tab, view code and paste this in and run it

Sub extractnumbers()
Dim RegExp As Object, Collection As Object, RegMatch As Object
Dim MyRange As Range, c As Range, Outstring As String
lastrow = Cells(Rows.Count, "D").End(xlUp).Row
For x = 1 To 2
Set RegExp = CreateObject("vbscript.RegExp")
With RegExp
.Global = True
If x = 1 Then
.Pattern = "\D"
Else
.Pattern = "\d"
End If
End With
Set MyRange = ActiveSheet.Range("d1:D" & lastrow)
For Each c In MyRange
Outstring = ""
Set Collection = RegExp.Execute(c.Value)
For Each RegMatch In Collection
Outstring = Outstring & RegMatch
Next
c.Offset(0, -(x + 1)) = Outstring
Next
Set Collection = Nothing
Set RegExp = Nothing
Set MyRange = Nothing
Next
End Sub


Mike

"pattlee" wrote:

I have a set of Alphanumeric data in Col D
I need to move only the numeric data to Col A
and then the Alpha data to Col B . The numeric data is variable so the
Data to Columns does not fit...
Example:
A B C D

So far can move the numeric data but stuck on the syntax for moving Alpha
Just getting started in Excel so would appreciate any help. thanx in Advance