Greetings all, I have a large spreadsheet which copies 100 text files into 100 worksheets, then embeds the compiled data into an email which sends every 30 minutes via a scheduled task. Each time the vba runs I have to stop what I'm doing due to the clipboard being tied up until after the file sends. I'd really like to speed things up a bit (or free up my clipboard) so it'll not be so disruptive to my other tasks. I'm including only the repetitive portion for a couple of the files as I believe the code I'm using for emailing is efficient as is. Any help in rewriting the code to make it more efficient would be greatly appreciated
HTML:
Public Sub ImportCMS()
Application.ScreenUpdating = FalseApplication.Calculation = xlCalculationManual
Dim File1, File2,... As String
Dim lastMod As String
File1 = ActiveWorkbook.Name
Sheets("account1").SelectRange("A10:R64").ClearContentsWS = ActiveSheet.Name
lastMod = FileDateTime("C:\Users\dturner\Desktop\ServiceLevelsSMS\PrevDayScriptOutput\account1.txt")
Range("A67") = lastModFile2 = "C:\Users\dturner\Desktop\ServiceLevelsSMS\IntervalScriptOutput\account1.txt"Workbooks.Open File2wFile = ActiveWorkbook.NameRange("A1:R55").SelectSelection.CopyWindows(File1).ActivateSheets(WS).ActivateRange("A10").ActivateSelection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _:=False, Transpose:=FalseApplication.CutCopyMode = FalseWorkbooks(wFile).Close FalseIf ActiveSheet.Name = "Sheet1" ThenApplication.GoTo Reference:="mTop"End If
Sheets("account2").SelectRange("A10:R64").ClearContentsWS = ActiveSheet.NamelastMod = FileDateTime("C:\Users\dturner\Desktop\ServiceLevelsSMS\PrevDayScriptOutput\account2.txt")Range("A67") = lastModFile3 = "C:\Users\dturner\Desktop\ServiceLevelsSMS\IntervalScriptOutput\account2.txt"Workbooks.Open File3wFile = ActiveWorkbook.NameRange("A1:R55").SelectSelection.CopyWindows(File1).ActivateSheets(WS).ActivateRange("A10").ActivateSelection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _:=False, Transpose:=FalseApplication.CutCopyMode = FalseWorkbooks(wFile).Close FalseIf ActiveSheet.Name = "Sheet1" ThenApplication.GoTo Reference:="mTop"End If
Application.Calculation = xlCalculationAutomatic
(...code for emailing)
Application.ScreenUpdating = True