SandsB
Well-known Member
- Joined
- Feb 13, 2007
- Messages
- 736
- Office Version
- 365
- Platform
- Windows
The macro below was written by somebody smarter than me. It deletes the contents (not the rows) of rows 3 through 50 for every tab in every file in E:\Reports\temp. Saved me a million man hours. I need something similar - something that will replace every occurrance of 2020 with 2021 in every tab in every file in the same folder. There's text in cells and thousands of links that point to 2020 files. All needs to be updated to 2021. I can do it manually by opening each file, selecting all the tabs together and doing one find/replace. But....there's way too many files for that.
What can I replace this line with? ws.Rows("3:50").ClearContents
-----
Sub BlankIt()
Application.ScreenUpdating = False
Dim ws As Worksheet
Dim directory As String
directory = "E:\Reports\temp"
Set fso = CreateObject("Scripting.FileSystemObject")
Set folder = fso.GetFolder(directory)
For Each file In folder.Files
Workbooks.Open directory & Application.PathSeparator & file.Name
For Each ws In Sheets
ws.Rows("3:50").ClearContents
Next ws
ActiveWorkbook.Close True
Next file
Application.ScreenUpdating = True
End Sub
What can I replace this line with? ws.Rows("3:50").ClearContents
-----
Sub BlankIt()
Application.ScreenUpdating = False
Dim ws As Worksheet
Dim directory As String
directory = "E:\Reports\temp"
Set fso = CreateObject("Scripting.FileSystemObject")
Set folder = fso.GetFolder(directory)
For Each file In folder.Files
Workbooks.Open directory & Application.PathSeparator & file.Name
For Each ws In Sheets
ws.Rows("3:50").ClearContents
Next ws
ActiveWorkbook.Close True
Next file
Application.ScreenUpdating = True
End Sub