IF the "LO" you want to omit is the first occurrence of the letters "LO" in
the file name, AND ALL the files are in the same folder AND you want to
possibly rename all the files in the folder, you can use code like the
following. Change the lines marked with '<<<<< to the appropriate values.
Sub RenameFiles()
Dim FName As String
Dim RenameCount As Long
Dim ErrCount As Long
Dim RenameStr As String
Dim ErrStr As String
Dim ReplaceName As String
ChDrive "C:" '<<<<< CHANGE
ChDir "C:\Test" '<<<<< CHANGE
FName = Dir("*.xls")
On Error Resume Next
Do Until FName = vbNullString
ReplaceName = Replace(expression:=FName, Find:="LO", _
Replace:=vbNullString, Count:=1, compare:=vbTextCompare)
Err.Clear
Name FName As ReplaceName
If Err.Number = 0 Then
RenameStr = RenameStr & vbCrLf & ReplaceName
RenameCount = RenameCount + 1
Else
ErrStr = ErrStr & vbCrLf & FName
ErrCount = ErrCount + 1
End If
FName = Dir()
Loop
MsgBox "Files Renamed: " & CStr(RenameCount) & vbCrLf & RenameStr
If ErrCount > 0 Then
MsgBox "Error renaming files: " & CStr(ErrCount) & vbCrLf & ErrStr
End If
End Sub
--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting
www.cpearson.com
(email on the web site)