Hi,
I'm trying to add one space in a series of file names which are in my col A.
First problem is how do I insert a test so that the inserted space will only apply to file names which are 13 or 14 characters long? How would I add another check to overwrite any files where the 5th cahacter is a "-"?
My code doesn't work as I get a runtime error on the line where I'm trying to insert the space.
Help appreaciated!
I'm trying to add one space in a series of file names which are in my col A.
First problem is how do I insert a test so that the inserted space will only apply to file names which are 13 or 14 characters long? How would I add another check to overwrite any files where the 5th cahacter is a "-"?
My code doesn't work as I get a runtime error on the line where I'm trying to insert the space.
Help appreaciated!
VBA Code:
Sub Add_one_space()
Dim i, x As Integer
Dim LastRow As Long
Sheets("FC plans").Select
LastRow = Cells(Rows.Count, "A").End(xlUp).Row
For x = 2 To LastRow Step 1
If Len("A" & x) < 13 Or Len("A" & x) > 14 Then
'how do I get to the next x from here?
End If
Range("A" & x) = Left(Range("A" & x), 4) & " " & Mid(Range("A" & x), 5, Len(Range("A" & x) - 4))
Next x
End Sub