File Renamer

Jaye7

Well-known Member
Joined
Jul 7, 2010
Messages
1,060
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
 

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.
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
 
Upvote 0
Sorry for the late reply, the script works great, thanks very much for your help.
 
Upvote 0

Forum statistics

Threads
1,214,647
Messages
6,120,722
Members
448,987
Latest member
marion_davis

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top