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,201
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

What is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.
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,215,731
Messages
6,126,538
Members
449,316
Latest member
sravya

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