Ok, I changed the code to the following, and it looks like it worked:
Sub CopyValuesToMaster()
'
' CopyValuesToMaster Macro This macro copies all of the individual TR files to a master district file as values so it's editable without blowing up the sheet
'
'
Dim wbData As Workbook, wbMain As Workbook
Dim wsMain As Worksheet, wsData As Worksheet
Dim LR As Long, NR As Long
Dim fPath As String, fName As String
Set wbMain = ThisWorkbook
'if files are stored in separate directory edit fPath
fPath = ThisWorkbook.Path & "\" 'don't forget the final \
fName = Dir(fPath & "*.xlsx") 'start looping through files one at a time
Application.ScreenUpdating = False
Do While Len(fName) > 0
If fName <> ThisWorkbook.Name Then
Set wbData = Workbooks.Open(fPath & fName)
Sheets("Snuff").Select
Range("Q12").Select
ActiveCell.FormulaR1C1 = "=R8C13"
Range("Q12").Select
Selection.AutoFill Destination:=Range("Q12:Q1000"), Type:=xlFillDefault
Range("Q12:Q1000").Select
With ActiveSheet
.UsedRange.Copy
.UsedRange.PasteSpecial xlPasteValues
.Rows(11).AutoFilter
.Rows(11).AutoFilter Field:=12, Criteria1:="<=0.8"
LR = .Range("A" & .Rows.Count).End(xlUp).Row
.Range("A11:A" & LR).EntireRow.Copy
End With
Sheets("Cigars").Select
Range("Q12").Select
ActiveCell.FormulaR1C1 = "=R8C11"
Range("Q12").Select
Selection.AutoFill Destination:=Range("Q12:Q1000"), Type:=xlFillDefault
Range("Q12:Q1000").Select
With ActiveSheet
.UsedRange.Copy
.UsedRange.PasteSpecial xlPasteValues
.Rows(11).AutoFilter
.Rows(11).AutoFilter Field:=12, Criteria1:="<=0.8"
LR = .Range("A" & .Rows.Count).End(xlUp).Row
.Range("A11:A" & LR).EntireRow.Copy
End With
Sheets("LL").Select
Range("K12").Select
ActiveCell.FormulaR1C1 = "=R8C7"
Range("K12").Select
Selection.AutoFill Destination:=Range("K12:K1000"), Type:=xlFillDefault
Range("K12:K1000").Select
With ActiveSheet
.UsedRange.Copy
.UsedRange.PasteSpecial xlPasteValues
.Rows(11).AutoFilter
.Rows(11).AutoFilter Field:=6, Criteria1:="<=0.8"
LR = .Range("A" & .Rows.Count).End(xlUp).Row
.Range("A11:A" & LR).EntireRow.Copy
End With
Sheets("Snus").Select
Range("K12").Select
ActiveCell.FormulaR1C1 = "=R8C7"
Range("K12").Select
Selection.AutoFill Destination:=Range("K12:K1000"), Type:=xlFillDefault
Range("K12:K1000").Select
With ActiveSheet
.UsedRange.Copy
.UsedRange.PasteSpecial xlPasteValues
.Rows(11).AutoFilter
.Rows(11).AutoFilter Field:=6, Criteria1:="<=0.8"
LR = .Range("A" & .Rows.Count).End(xlUp).Row
.Range("A11:A" & LR).EntireRow.Copy
End With
Sheets("Overall ($)").Select
Range("T11").Select
ActiveCell.FormulaR1C1 = "=R8C7"
Range("T11").Select
Selection.AutoFill Destination:=Range("T11:T1000"), Type:=xlFillDefault
Range("T11:T1000").Select
With ActiveSheet
.UsedRange.Copy
.UsedRange.PasteSpecial xlPasteValues
.Rows(10).AutoFilter
.Rows(10).AutoFilter Field:=14, Criteria1:="<=0.8"
LR = .Range("A" & .Rows.Count).End(xlUp).Row
.Range("A10:A" & LR).EntireRow.Copy
End With
For Each wsData In wbData.Worksheets
Set wsMain = wbMain.Sheets(wsData.Name)
NR = wsMain.Range("A" & Rows.Count).End(xlUp).Row + 1
With wsData
LR = .Range("A" & .Rows.Count).End(xlUp).Row
.Range("A11:A" & LR).EntireRow.Copy
wsMain.Range("A" & NR).PasteSpecial xlPasteValuesAndNumberFormats
.AutoFilterMode = False
.UsedRange.Copy
.UsedRange.PasteSpecial xlPasteValues
End With
Next wsData
fName = Left(fName, InStrRev(fName, ".") - 1) & "1.xlsx"
wbData.SaveAs fPath & "Values\" & fName, FileFormat:=51
wbData.Close False
End If
fName = Dir 'queue up next filename
Loop
Application.ScreenUpdating = True
End Sub
Do you see any potential issues with it?? Also, it runs fairly slow, is it because I'm making it go sheet by sheet??
Thanks again for all your help.
Bookmarks