Conell8383
Board Regular
- Joined
- Jul 26, 2016
- Messages
- 66
Hi all. I hope you can help.
I need a macro that can remove numbers from the beginning of a cell only. I have seen many posts on here but none that solve my issue. The issue I am facing is that in Column G I have unwanted numbers at the start of every cell I would like some code that can go through column G remove only the numbers at the start of the cell.
I have attached a picture for better understanding.
I have found some code on here but i deletes TEXT and leaves numbers can this be modified?
CODE
As always any and all help is greatly appreciated.
I need a macro that can remove numbers from the beginning of a cell only. I have seen many posts on here but none that solve my issue. The issue I am facing is that in Column G I have unwanted numbers at the start of every cell I would like some code that can go through column G remove only the numbers at the start of the cell.
I have attached a picture for better understanding.

I have found some code on here but i deletes TEXT and leaves numbers can this be modified?
CODE
Code:
Public Function PullOnly(strSrc As String, CharType As String)
Dim RE As RegExp
Dim regexpPattern As String
Set RE = New RegExp
CharType = LCase(CharType)
Select Case CharType
Case Is = "digits":
regexpPattern = "\D"
Case Is = "letters":
regexpPattern = "\d"
Case Else:
regexpPattern = ""
End Select
RE.Pattern = regexpPattern
RE.Global = True
PullOnly = RE.Replace(strSrc, "")
End Function
Sub LeaveNumbers()
Dim cCell As Range
For Each cCell In Selection
If cCell <> "" Then
cCell.Value = "'" & PullOnly(cCell.Text, "digits")
End If
Next cCell
End Sub
Last edited: