macro to check list of names for characters that cant be in a save name?

tonywatsonhelp

Well-known Member
Joined
Feb 24, 2014
Messages
3,204
Office Version
  1. 365
  2. 2019
  3. 2016
Platform
  1. Windows
Hi Eeryone,
i have a list of names that i use to create documents but i noticed some of them have characters that can't be used in a file name such as "/"
i dont know all of them but is there a macro i could run that would check each cell in column C range C8:C5008 and if the name is not compatible with save highlight it in yellow and send a macro saying some names are not compatible or change the bad parts for a "-"? anything so i dont keep getting a debug?

Thanks

RTony
 

Excel Facts

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.
You could use this function, to convert strings to valid workbook names
VBA Code:
Function ValidWBName(arg As String) As String
' Andrew Poulsom
    Dim RegEx As Object
    Set RegEx = CreateObject("VBScript.RegExp")
    With RegEx
        .Pattern = "[\\/:\*\?""<>\|]"
        .Global = True
        ValidWBName = .Replace(arg, "_")
    End With
End Function
 
Upvote 0

Forum statistics

Threads
1,216,830
Messages
6,132,962
Members
449,772
Latest member
Burkie

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