Removing an apostrophy ' from the front of filename

whatzzup

New Member
Joined
Jan 11, 2011
Messages
7
I have over 200 excel files that has a apostrophy infron of the file name and wanted to remove them, the filename is currently like this '4123 Flooring, '1211 Window etc., and i want them to be 4123 Flooring and 1211 Window respectively, is there a way to change them in a simple way without doint it one at a time?
 
where it says "C:\" replace that with the FOLDER NAME that has the spreadsheets you are fixing.

Put this code in a module in your personal macro workbook.
you do NOT need to put the name of a spreadsheet ANYWHERE in that code.


sidenote: JackDanIce,

I've been using codes like this to do things for all sheets in a folder, but I don't understand how the loop actually works. What is the first file it would look at? what order? and how does it advance?
 
Last edited:
Upvote 0

Excel Facts

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.
You need to amend the Dir line first:

Rich (BB code):
Public Sub RenameFile()
    Const strPath As String = "C:\"
    Dim strFileName As String
 
    strFileName = Dir$(strPath & "*")
 
    Do While Len(strFileName) > 0
        If strFileName Like "*'*" Then
            Name strPath & strFileName As strPath & Replace$(strFileName, "'", "")
        End If
        strFileName = Dir$
    Loop
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,522
Messages
6,179,297
Members
452,903
Latest member
Knuddeluff

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