I am currently using a macro that eliminates every occurrence where a colon, blank space or zero is the very first character in any cell within columns A,C and E. The problem I am having is that I now need to have formulas in those columns to perform other functions as well and when I run the macro it still properly gets rid of the unwanted characters as it should however, it also deletes all the formulas from the subsequent cells all the way down each column. Hopefully someone can help with the suggestion on how to overcome the problem and still have the macro eliminate the unwanted characters while preserving the formulas that exist in the subsequent cells. Below is the code I'm using:
Sub RemoveLeadingSpacesColonsAndZeroes_v2()
Dim r As Long, c As Long, Data As Variant, i As Long, s As String
With Range("A1:G" & Cells(Rows.Count, "A").End(xlUp).Row)
Data = .Value
For r = 1 To UBound(Data, 1)
For c = 1 To UBound(Data, 2)
s = Data(r, c)
i = 1
Do While Mid(s, i, 1) Like "[ :0]"
i = i + 1
Loop
If i > 1 Then Data(r, c) = Mid(s, i)
Next
Next
.Value = Data
End With
End Sub
Sub RemoveLeadingSpacesColonsAndZeroes_v2()
Dim r As Long, c As Long, Data As Variant, i As Long, s As String
With Range("A1:G" & Cells(Rows.Count, "A").End(xlUp).Row)
Data = .Value
For r = 1 To UBound(Data, 1)
For c = 1 To UBound(Data, 2)
s = Data(r, c)
i = 1
Do While Mid(s, i, 1) Like "[ :0]"
i = i + 1
Loop
If i > 1 Then Data(r, c) = Mid(s, i)
Next
Next
.Value = Data
End With
End Sub