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

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.
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,215,341
Messages
6,124,391
Members
449,155
Latest member
ravioli44

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