billandrew
Well-known Member
- Joined
- Mar 9, 2014
- Messages
- 743
Good evening all
I am adding a semi colon in string of 3 after the 1st number & a semi colon in string of 4 after the 2nd number utilizing the below code. The issue I am having is at the end of the range when additional values are entered the cell returns 0:00. when the code is run again the value entered is correct with the semi colon and cell formatting.
Thanks for any assistance
Sub InsertSemiColonw()
Dim lr As Long
Dim i As Long
lr = Range("B" & Rows.Count).End(xlUp).Row
For i = 2 To lr
If Len(Cells(i, "B")) = 3 Then
Cells(i, "B") = Left(Cells(i, "B"), 1) & ":" & Right(Cells(i, "B"), 1)
ElseIf Len(Cells(i, "B")) = 4 Then
Cells(i, "B") = Left(Cells(i, "B"), 2) & ":" & Right(Cells(i, "B"), 2)
End If
Next
End Sub
I am adding a semi colon in string of 3 after the 1st number & a semi colon in string of 4 after the 2nd number utilizing the below code. The issue I am having is at the end of the range when additional values are entered the cell returns 0:00. when the code is run again the value entered is correct with the semi colon and cell formatting.
Thanks for any assistance
Sub InsertSemiColonw()
Dim lr As Long
Dim i As Long
lr = Range("B" & Rows.Count).End(xlUp).Row
For i = 2 To lr
If Len(Cells(i, "B")) = 3 Then
Cells(i, "B") = Left(Cells(i, "B"), 1) & ":" & Right(Cells(i, "B"), 1)
ElseIf Len(Cells(i, "B")) = 4 Then
Cells(i, "B") = Left(Cells(i, "B"), 2) & ":" & Right(Cells(i, "B"), 2)
End If
Next
End Sub