Need macro that can search across directory of xls files and delete highlighting of any color ('no fill') where found in files.
Need macro that can search across directory of xls files and delete highlighting of any color ('no fill') where found in files.
Be careful what you wish for!
This macro opens every Excel file in the specified directory, and removes all highlighting from the used range of every worksheet in the workbook, then saves the file.
I advise you to create a dummy directory and copy some files in to test it first to make sure it is doing what you want, as it will irreversibly change every file in your directory.
Also, if there are lots of files, or they are large, it could take a long time and/or freeze your computer.
![]()
Sub highlight_remove() Dim ws As Worksheet, MyFile As String, MyDir As String, ThisFile As String ThisFile = ActiveWorkbook.Name ' does not change or close the active workbook MyDir = "C:\My Documents\Test\" 'directory to change files - needs concluding "\" MyFile = Dir(MyDir & "*.xl*") 'select only excel files Do While MyFile <> "" If MyFile <> ThisFile Then Workbooks.Open MyDir & MyFile For Each ws In ActiveWorkbook.Worksheets ws.UsedRange.Interior.Color = xlNone Next ws ActiveWorkbook.Save ActiveWorkbook.Close End If MyFile = Dir() Loop End Sub
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks