File Renamer

Jaye7

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

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number
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,224,586
Messages
6,179,730
Members
452,939
Latest member
WCrawford

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