File Renamer

Jaye7

Well-known Member
Joined
Jul 7, 2010
Messages
1,056
I found the following script which renames files, can someone please help with a script which will highlight each cell that wasn't changed as yellow.

Code:
Sub ReName()

Dim r As Range, msg As String
For Each r In Range("a1", Range("a" & Rows.Count).End(xlUp))
   If (r.Value <> "") * (r.Offset(, 1).Value <> "") Then
       If Dir(r.Value) <> "" Then
           Name r.Value As r.Offset(, 1).Value
       Else
           msg = msg & vbLf & r.Value
       End If
    End If
Next
MsgBox IIf(Len(msg) > 0, "Missing following file(s)" & msg, "Done")
End Sub
 

Some videos you may like

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.

nightcrawler23

Well-known Member
Joined
Sep 24, 2009
Messages
721
TRY,

Code:
Sub ReName()

Dim r As Range, msg As String
For Each r In Range("a1", Range("a" & Rows.Count).End(xlUp))
   If (r.Value <> "") * (r.Offset(, 1).Value <> "") Then
       If Dir(r.Value) <> "" Then
           Name r.Value As r.Offset(, 1).Value
       Else
           msg = msg & vbLf & r.Value
           [COLOR="Red"]r.Interior.Color = 65535[/COLOR]
       End If
    End If
Next
MsgBox IIf(Len(msg) > 0, "Missing following file(s)" & msg, "Done")
End Sub
 

Jaye7

Well-known Member
Joined
Jul 7, 2010
Messages
1,056
Sorry for the late reply, the script works great, thanks very much for your help.
 

Watch MrExcel Video

Forum statistics

Threads
1,118,167
Messages
5,570,593
Members
412,330
Latest member
carlosjw
Top