hi all
I have 2 cells
3:00pm
3:00
I want to get rid of the : from each cell and change it to .
I found/edited this code which works for 3:00pm but not 3:00?
Also if I want to add the word "from" to the start of each cell using code below it works for 3:00pm but turns 3:00 to a fraction of a number
Any help appreciated
I have 2 cells
3:00pm
3:00
I want to get rid of the : from each cell and change it to .
I found/edited this code which works for 3:00pm but not 3:00?
Code:
Sub Remove()
Dim rgxRegExp As Object
Dim rngCell As Range, rngRange As Range
Dim abc As String
abc = "."
Set rngRange = Sheet1.Range("A1:A100")
Set rgxRegExp = CreateObject("VBScript.RegExp")
rgxRegExp.Global = True
rgxRegExp.Pattern = ":" 'what we want to replace
With Application
.Calculation = xlCalculationManual
.EnableEvents = False
.ScreenUpdating = False
End With
For Each rngCell In rngRange.SpecialCells(xlCellTypeVisible)
rngCell.Value = rgxRegExp.Replace(rngCell.Value, abc)
Next
With Application
.Calculation = xlCalculationAutomatic
.EnableEvents = True
.ScreenUpdating = True
End With
End Sub
Also if I want to add the word "from" to the start of each cell using code below it works for 3:00pm but turns 3:00 to a fraction of a number
Code:
Sub AppendToExistingOnLeft()
Columns ("a:a").select
Dim c As Range
For Each c In Selection
If c.Value <> "" Then c.Value = "From " & c.Value
Next
End Sub
Any help appreciated