Code Review Asked by CDay on December 28, 2021
I have a macro created by my predecessor that I run on a monthly basis. However, it does take a while to get through, and I would like to clean it up for efficiency please.
It copies data from multiple Workbooks:
WholesaleReportingMarket6 ScorecardTemplates52 Wk Data.csv
WholesaleReportingMarket6 ScorecardTemplates26 Wk Data.csv
etc..
and pastes to the Destination Worksheet:
Workbooks("KROGER M6 SCORECARD TEMPLATE.xlsm").Worksheets("COMBINED")
Here is the macro, and I keep thinking there are duplicate variables. But maybe there’s a reason that I don’t understand yet. Thoughts?
Sub DataPaste()
'Turn Off Screen Updates
Application.ScreenUpdating = False
Application.DisplayAlerts = False
Application.Calculation = xlCalculationManual
'Weekly Division Tab:
'Open Weekly Data Workbook
Workbooks.Open "O:WholesaleReportingMarket6 ScorecardTemplatesWeekly Data.csv"
'Remove Current Data
Dim aDataPaste As Worksheet
Set aDataPaste = Workbooks("KROGER M6 SCORECARD TEMPLATE.xlsm").Worksheets("Weekly Division")
Dim TemplateLastRow As Long
TemplateLastRow = aDataPaste.Cells(aDataPaste.Rows.Count, "B").End(xlUp).Offset(1).Row
Workbooks("KROGER M6 SCORECARD TEMPLATE.xlsm").Worksheets("Weekly Division").Range("A1:A12").ClearContents
Workbooks("KROGER M6 SCORECARD TEMPLATE.xlsm").Worksheets("Weekly Division").Range("A15:Z" & TemplateLastRow).ClearContents
'Copy Title Information
Workbooks("Weekly Data.csv").Worksheets("Weekly Data").Range("A1:A12").Copy Workbooks("KROGER M6 SCORECARD TEMPLATE.xlsm").Worksheets("Weekly Division").Range("A1:A12")
'Copy data
Dim aTemplate As Worksheet
Dim DataLastRow As Long
Set aTemplate = Workbooks("Weekly Data.csv").Worksheets("Weekly Data")
DataLastRow = aTemplate.Cells(aTemplate.Rows.Count, "B").End(xlUp).Offset(1).Row
Workbooks("Weekly Data.csv").Worksheets("Weekly Data").Range("A17:I" & DataLastRow).Copy Workbooks("KROGER M6 SCORECARD TEMPLATE.xlsm").Worksheets("Weekly Division").Range("A15:I" & DataLastRow)
Workbooks("Weekly Data.csv").Worksheets("Weekly Data").Range("J17:N" & DataLastRow).Copy Workbooks("KROGER M6 SCORECARD TEMPLATE.xlsm").Worksheets("Weekly Division").Range("L15:P" & DataLastRow)
Workbooks("Weekly Data.csv").Worksheets("Weekly Data").Range("O17:P" & DataLastRow).Copy Workbooks("KROGER M6 SCORECARD TEMPLATE.xlsm").Worksheets("Weekly Division").Range("V15:W" & DataLastRow)
'Close Weekly Data Workbook
Workbooks("Weekly Data.csv").Close SaveChanges:=False
'Combined Tab:
'Remove Current Data
Dim bDataPaste As Worksheet
Set bDataPaste = Workbooks("KROGER M6 SCORECARD TEMPLATE.xlsm").Worksheets("COMBINED")
Dim bTemplateLastRow As Long
bTemplateLastRow = bDataPaste.Cells(bDataPaste.Rows.Count, "B").End(xlUp).Offset(1).Row
Workbooks("KROGER M6 SCORECARD TEMPLATE.xlsm").Worksheets("COMBINED").Range("A5:U" & bTemplateLastRow).ClearContents
'Copy 52 Wk Data
Workbooks.Open "O:WholesaleReportingMarket6 ScorecardTemplates52 Wk Data.csv"
Dim cWkData As Worksheet
Dim cDataPaste As Worksheet
Set cWkData = Workbooks("52 Wk Data.csv").Worksheets("52 Wk Data")
Set cDataPaste = Workbooks("KROGER M6 SCORECARD TEMPLATE.xlsm").Worksheets("COMBINED")
Dim cTemplateLastRow As Long
Dim cCopyLastRow As Long
cTemplateLastRow = cDataPaste.Cells(cDataPaste.Rows.Count, "B").End(xlUp).Offset(1).Row
cCopyLastRow = cWkData.Cells(cWkData.Rows.Count, "A").End(xlUp).Row
cWkData.Range("A18:H" & cCopyLastRow).Copy cDataPaste.Range("B5:I" & bTemplateLastRow)
cWkData.Range("I18:R" & cCopyLastRow).Copy cDataPaste.Range("L5:U" & cTemplateLastRow)
'Add Dates
Dim cTemplateLastRowb As Long
Dim cTemplateLastRowc As Long
cTemplateLastRowb = cDataPaste.Cells(cDataPaste.Rows.Count, "B").End(xlUp).Row
cTemplateLastRowc = cDataPaste.Cells(cDataPaste.Rows.Count, "B").End(xlUp).Offset(1).Row
Dim cFirstRow As Range
Dim cLastRow As Range
Set cFirstRow = Workbooks("KROGER M6 SCORECARD TEMPLATE.xlsm").Worksheets("COMBINED").Range("A5")
Set cLastRow = Workbooks("KROGER M6 SCORECARD TEMPLATE.xlsm").Worksheets("COMBINED").Range("A" & cTemplateLastRowb)
Range(cFirstRow, cLastRow).Formula = "=concatenate(""Latest 52 Wks - Ending "",left(right('Weekly Division'!$A$4,24),23))"
Workbooks("52 Wk Data.csv").Close SaveChanges:=False
'Copy 26 Wk Data
Workbooks.Open "O:WholesaleReportingMarket6 ScorecardTemplates26 Wk Data.csv"
Dim dWkData As Worksheet
Dim dDataPaste As Worksheet
Set dWkData = Workbooks("26 Wk Data.csv").Worksheets("26 Wk Data")
Set dDataPaste = Workbooks("KROGER M6 SCORECARD TEMPLATE.xlsm").Worksheets("COMBINED")
Dim dTemplateLastRow As Long
Dim dCopyLastRow As Long
dTemplateLastRow = dDataPaste.Cells(dDataPaste.Rows.Count, "B").End(xlUp).Offset(1).Row
dCopyLastRow = dWkData.Cells(dWkData.Rows.Count, "A").End(xlUp).Row
dWkData.Range("A18:H" & dCopyLastRow).Copy dDataPaste.Range("B" & dTemplateLastRow)
dWkData.Range("I18:R" & dCopyLastRow).Copy dDataPaste.Range("L" & dTemplateLastRow)
'Add Dates
Dim dTemplateLastRowb As Long
Dim dTemplateLastRowc As Long
dTemplateLastRowb = dDataPaste.Cells(dDataPaste.Rows.Count, "B").End(xlUp).Row
dTemplateLastRowc = dDataPaste.Cells(dDataPaste.Rows.Count, "B").End(xlUp).Offset(1).Row
Dim dFirstRow As Range
Dim dLastRow As Range
Set dFirstRow = Workbooks("KROGER M6 SCORECARD TEMPLATE.xlsm").Worksheets("COMBINED").Range("A" & cTemplateLastRowc)
Set dLastRow = Workbooks("KROGER M6 SCORECARD TEMPLATE.xlsm").Worksheets("COMBINED").Range("A" & dTemplateLastRowb)
Range(dFirstRow, dLastRow).Formula = "=concatenate(""Latest 26 Wks - Ending "",left(right('Weekly Division'!$A$4,24),23))"
Workbooks("26 Wk Data.csv").Close SaveChanges:=False
'Copy 13 Wk Data
Workbooks.Open "O:WholesaleReportingMarket6 ScorecardTemplates13 Wk Data.csv"
Dim eWkData As Worksheet
Dim eDataPaste As Worksheet
Set eWkData = Workbooks("13 Wk Data.csv").Worksheets("13 Wk Data")
Set eDataPaste = Workbooks("KROGER M6 SCORECARD TEMPLATE.xlsm").Worksheets("COMBINED")
Dim eTemplateLastRow As Long
Dim eCopyLastRow As Long
eTemplateLastRow = eDataPaste.Cells(eDataPaste.Rows.Count, "B").End(xlUp).Offset(1).Row
eCopyLastRow = eWkData.Cells(eWkData.Rows.Count, "A").End(xlUp).Row
eWkData.Range("A18:H" & eCopyLastRow).Copy eDataPaste.Range("B" & eTemplateLastRow)
eWkData.Range("I18:R" & eCopyLastRow).Copy eDataPaste.Range("L" & eTemplateLastRow)
'Add Dates
Dim eTemplateLastRowb As Long
Dim eTemplateLastRowc As Long
eTemplateLastRowb = eDataPaste.Cells(eDataPaste.Rows.Count, "B").End(xlUp).Row
eTemplateLastRowc = eDataPaste.Cells(eDataPaste.Rows.Count, "B").End(xlUp).Offset(1).Row
Dim eFirstRow As Range
Dim eLastRow As Range
Set eFirstRow = Workbooks("KROGER M6 SCORECARD TEMPLATE.xlsm").Worksheets("COMBINED").Range("A" & dTemplateLastRowc)
Set eLastRow = Workbooks("KROGER M6 SCORECARD TEMPLATE.xlsm").Worksheets("COMBINED").Range("A" & eTemplateLastRowb)
Range(eFirstRow, eLastRow).Formula = "=concatenate(""Latest 13 Wks - Ending "",left(right('Weekly Division'!$A$4,24),23))"
Workbooks("13 Wk Data.csv").Close SaveChanges:=False
'Copy 4 Wk Data
Workbooks.Open "O:WholesaleReportingMarket6 ScorecardTemplates4 Wk Data.csv"
Dim fWkData As Worksheet
Dim fDataPaste As Worksheet
Set fWkData = Workbooks("4 Wk Data.csv").Worksheets("4 Wk Data")
Set fDataPaste = Workbooks("KROGER M6 SCORECARD TEMPLATE.xlsm").Worksheets("COMBINED")
Dim fTemplateLastRow As Long
Dim fCopyLastRow As Long
fTemplateLastRow = fDataPaste.Cells(fDataPaste.Rows.Count, "B").End(xlUp).Offset(1).Row
fCopyLastRow = fWkData.Cells(fWkData.Rows.Count, "A").End(xlUp).Row
fWkData.Range("A18:H" & fCopyLastRow).Copy fDataPaste.Range("B" & fTemplateLastRow)
fWkData.Range("I18:R" & fCopyLastRow).Copy fDataPaste.Range("L" & fTemplateLastRow)
'Add Dates
Dim fTemplateLastRowb As Long
Dim fTemplateLastRowc As Long
fTemplateLastRowb = fDataPaste.Cells(fDataPaste.Rows.Count, "B").End(xlUp).Row
fTemplateLastRowc = fDataPaste.Cells(fDataPaste.Rows.Count, "B").End(xlUp).Offset(1).Row
Dim fFirstRow As Range
Dim fLastRow As Range
Set fFirstRow = Workbooks("KROGER M6 SCORECARD TEMPLATE.xlsm").Worksheets("COMBINED").Range("A" & eTemplateLastRowc)
Set fLastRow = Workbooks("KROGER M6 SCORECARD TEMPLATE.xlsm").Worksheets("COMBINED").Range("A" & fTemplateLastRowb)
Range(fFirstRow, fLastRow).Formula = "=concatenate(""Latest 04 Wks - Ending "",left(right('Weekly Division'!$A$4,24),23))"
Workbooks("4 Wk Data.csv").Close SaveChanges:=False
'Copy YTD Data
Workbooks.Open "O:WholesaleReportingMarket6 ScorecardTemplatesYTD Data.csv"
Dim gWkData As Worksheet
Dim gDataPaste As Worksheet
Set gWkData = Workbooks("YTD Data.csv").Worksheets("YTD Data")
Set gDataPaste = Workbooks("KROGER M6 SCORECARD TEMPLATE.xlsm").Worksheets("COMBINED")
Dim gTemplateLastRow As Long
Dim gCopyLastRow As Long
gTemplateLastRow = gDataPaste.Cells(gDataPaste.Rows.Count, "B").End(xlUp).Offset(1).Row
gCopyLastRow = gWkData.Cells(gWkData.Rows.Count, "A").End(xlUp).Row
gWkData.Range("A18:H" & gCopyLastRow).Copy gDataPaste.Range("B" & gTemplateLastRow)
gWkData.Range("I18:R" & gCopyLastRow).Copy gDataPaste.Range("L" & gTemplateLastRow)
'Add Dates
Dim gTemplateLastRowb As Long
Dim gTemplateLastRowc As Long
gTemplateLastRowb = gDataPaste.Cells(gDataPaste.Rows.Count, "B").End(xlUp).Row
gTemplateLastRowc = gDataPaste.Cells(gDataPaste.Rows.Count, "B").End(xlUp).Offset(1).Row
Dim gFirstRow As Range
Dim gLastRow As Range
Set gFirstRow = Workbooks("KROGER M6 SCORECARD TEMPLATE.xlsm").Worksheets("COMBINED").Range("A" & fTemplateLastRowc)
Set gLastRow = Workbooks("KROGER M6 SCORECARD TEMPLATE.xlsm").Worksheets("COMBINED").Range("A" & gTemplateLastRowb)
Range(gFirstRow, gLastRow).Formula = "=concatenate(""Kroger YTD - Ending "",left(right('Weekly Division'!$A$4,24),23))"
Workbooks("YTD Data.csv").Close SaveChanges:=False
'Stores Selling Summary Tab:
'Remove Current Data
Dim hDataPaste As Worksheet
Set hDataPaste = Workbooks("KROGER M6 SCORECARD TEMPLATE.xlsm").Worksheets("stores selling summary")
Dim hTemplateLastRow As Long
hTemplateLastRow = hDataPaste.Cells(hDataPaste.Rows.Count, "B").End(xlUp).Offset(1).Row
Workbooks("KROGER M6 SCORECARD TEMPLATE.xlsm").Worksheets("stores selling summary").Range("A6:N" & hTemplateLastRow).ClearContents
'Copy 52 Wk Data
Workbooks.Open "O:WholesaleReportingMarket6 ScorecardTemplatesStores Selling 52 Wks.csv"
Dim iStrData As Worksheet
Dim iDataPaste As Worksheet
Set iStrData = Workbooks("Stores Selling 52 Wks.csv").Worksheets("Stores Selling 52 Wks")
Set iDataPaste = Workbooks("KROGER M6 SCORECARD TEMPLATE.xlsm").Worksheets("stores selling summary")
Dim iTemplateLastRow As Long
Dim iCopyLastRow As Long
iTemplateLastRow = iDataPaste.Cells(iDataPaste.Rows.Count, "B").End(xlUp).Offset(1).Row
iCopyLastRow = iStrData.Cells(iStrData.Rows.Count, "A").End(xlUp).Row
iStrData.Range("A13:B" & iCopyLastRow).Copy iDataPaste.Range("B6:C" & iTemplateLastRow)
iStrData.Range("C13:C" & iCopyLastRow).Copy iDataPaste.Range("G6:G" & iTemplateLastRow)
iStrData.Range("F13:I" & iCopyLastRow).Copy iDataPaste.Range("I6:L" & iTemplateLastRow)
iStrData.Range("D13:E" & iCopyLastRow).Copy iDataPaste.Range("M6:N" & iTemplateLastRow)
'Add Dates
Dim iTemplateLastRowb As Long
Dim iTemplateLastRowc As Long
iTemplateLastRowb = iDataPaste.Cells(iDataPaste.Rows.Count, "B").End(xlUp).Row
iTemplateLastRowc = iDataPaste.Cells(iDataPaste.Rows.Count, "B").End(xlUp).Offset(1).Row
Dim iFirstRow As Range
Dim iLastRow As Range
Set iFirstRow = Workbooks("KROGER M6 SCORECARD TEMPLATE.xlsm").Worksheets("stores selling summary").Range("A6")
Set iLastRow = Workbooks("KROGER M6 SCORECARD TEMPLATE.xlsm").Worksheets("stores selling summary").Range("A" & iTemplateLastRowb)
Range(iFirstRow, iLastRow).Formula = "=concatenate(""Latest 52 Wks - Ending "",left(right('Weekly Division'!$A$4,24),23))"
Workbooks("Stores Selling 52 Wks.csv").Close SaveChanges:=False
'Copy 26 Wk Data
Workbooks.Open "O:WholesaleReportingMarket6 ScorecardTemplatesStores Selling 26 Wks.csv"
Dim jStrData As Worksheet
Dim jDataPaste As Worksheet
Set jStrData = Workbooks("Stores Selling 26 Wks.csv").Worksheets("Stores Selling 26 Wks")
Set jDataPaste = Workbooks("KROGER M6 SCORECARD TEMPLATE.xlsm").Worksheets("stores selling summary")
Dim jTemplateLastRow As Long
Dim jCopyLastRow As Long
jTemplateLastRow = jDataPaste.Cells(jDataPaste.Rows.Count, "B").End(xlUp).Offset(1).Row
jCopyLastRow = jStrData.Cells(jStrData.Rows.Count, "A").End(xlUp).Row
jStrData.Range("A13:B" & jCopyLastRow).Copy jDataPaste.Range("B" & jTemplateLastRow)
jStrData.Range("C13:C" & jCopyLastRow).Copy jDataPaste.Range("G" & jTemplateLastRow)
jStrData.Range("F13:I" & jCopyLastRow).Copy jDataPaste.Range("I" & jTemplateLastRow)
jStrData.Range("D13:E" & jCopyLastRow).Copy jDataPaste.Range("M" & jTemplateLastRow)
'Add Dates
Dim jTemplateLastRowb As Long
Dim jTemplateLastRowc As Long
jTemplateLastRowb = jDataPaste.Cells(jDataPaste.Rows.Count, "B").End(xlUp).Row
jTemplateLastRowc = jDataPaste.Cells(jDataPaste.Rows.Count, "B").End(xlUp).Offset(1).Row
Dim jFirstRow As Range
Dim jLastRow As Range
Set jFirstRow = Workbooks("KROGER M6 SCORECARD TEMPLATE.xlsm").Worksheets("stores selling summary").Range("A" & iTemplateLastRowc)
Set jLastRow = Workbooks("KROGER M6 SCORECARD TEMPLATE.xlsm").Worksheets("stores selling summary").Range("A" & jTemplateLastRowb)
Range(jFirstRow, jLastRow).Formula = "=concatenate(""Latest 26 Wks - Ending "",left(right('Weekly Division'!$A$4,24),23))"
Workbooks("Stores Selling 26 Wks.csv").Close SaveChanges:=False
'Copy 13 Wk Data
Workbooks.Open "O:WholesaleReportingMarket6 ScorecardTemplatesStores Selling 13 Wks.csv"
Dim kStrData As Worksheet
Dim kDataPaste As Worksheet
Set kStrData = Workbooks("Stores Selling 13 Wks.csv").Worksheets("Stores Selling 13 Wks")
Set kDataPaste = Workbooks("KROGER M6 SCORECARD TEMPLATE.xlsm").Worksheets("stores selling summary")
Dim kTemplateLastRow As Long
Dim kCopyLastRow As Long
kTemplateLastRow = kDataPaste.Cells(kDataPaste.Rows.Count, "B").End(xlUp).Offset(1).Row
kCopyLastRow = kStrData.Cells(kStrData.Rows.Count, "A").End(xlUp).Row
kStrData.Range("A13:B" & kCopyLastRow).Copy kDataPaste.Range("B" & kTemplateLastRow)
kStrData.Range("C13:C" & kCopyLastRow).Copy kDataPaste.Range("G" & kTemplateLastRow)
kStrData.Range("F13:I" & kCopyLastRow).Copy kDataPaste.Range("I" & kTemplateLastRow)
kStrData.Range("D13:E" & kCopyLastRow).Copy kDataPaste.Range("M" & kTemplateLastRow)
'Add Dates
Dim kTemplateLastRowb As Long
Dim kTemplateLastRowc As Long
kTemplateLastRowb = kDataPaste.Cells(kDataPaste.Rows.Count, "B").End(xlUp).Row
kTemplateLastRowc = kDataPaste.Cells(kDataPaste.Rows.Count, "B").End(xlUp).Offset(1).Row
Dim kFirstRow As Range
Dim kLastRow As Range
Set kFirstRow = Workbooks("KROGER M6 SCORECARD TEMPLATE.xlsm").Worksheets("stores selling summary").Range("A" & jTemplateLastRowc)
Set kLastRow = Workbooks("KROGER M6 SCORECARD TEMPLATE.xlsm").Worksheets("stores selling summary").Range("A" & kTemplateLastRowb)
Range(kFirstRow, kLastRow).Formula = "=concatenate(""Latest 13 Wks - Ending "",left(right('Weekly Division'!$A$4,24),23))"
Workbooks("Stores Selling 13 Wks.csv").Close SaveChanges:=False
'Copy 4 Wk Data
Workbooks.Open "O:WholesaleReportingMarket6 ScorecardTemplatesStores Selling 4 Wks.csv"
Dim lStrData As Worksheet
Dim lDataPaste As Worksheet
Set lStrData = Workbooks("Stores Selling 4 Wks.csv").Worksheets("Stores Selling 4 Wks")
Set lDataPaste = Workbooks("KROGER M6 SCORECARD TEMPLATE.xlsm").Worksheets("stores selling summary")
Dim lTemplateLastRow As Long
Dim lCopyLastRow As Long
lTemplateLastRow = lDataPaste.Cells(lDataPaste.Rows.Count, "B").End(xlUp).Offset(1).Row
lCopyLastRow = lStrData.Cells(lStrData.Rows.Count, "A").End(xlUp).Row
lStrData.Range("A13:B" & lCopyLastRow).Copy lDataPaste.Range("B" & lTemplateLastRow)
lStrData.Range("C13:C" & lCopyLastRow).Copy lDataPaste.Range("G" & lTemplateLastRow)
lStrData.Range("F13:I" & lCopyLastRow).Copy lDataPaste.Range("I" & lTemplateLastRow)
lStrData.Range("D13:E" & lCopyLastRow).Copy lDataPaste.Range("M" & lTemplateLastRow)
'Add Dates
Dim lTemplateLastRowb As Long
Dim lTemplateLastRowc As Long
lTemplateLastRowb = lDataPaste.Cells(lDataPaste.Rows.Count, "B").End(xlUp).Row
lTemplateLastRowc = lDataPaste.Cells(lDataPaste.Rows.Count, "B").End(xlUp).Offset(1).Row
Dim lFirstRow As Range
Dim lLastRow As Range
Set lFirstRow = Workbooks("KROGER M6 SCORECARD TEMPLATE.xlsm").Worksheets("stores selling summary").Range("A" & kTemplateLastRowc)
Set lLastRow = Workbooks("KROGER M6 SCORECARD TEMPLATE.xlsm").Worksheets("stores selling summary").Range("A" & lTemplateLastRowb)
Range(lFirstRow, lLastRow).Formula = "=concatenate(""Latest 04 Wks - Ending "",left(right('Weekly Division'!$A$4,24),23))"
Workbooks("Stores Selling 4 Wks.csv").Close SaveChanges:=False
'Copy YTD Data
Workbooks.Open "O:WholesaleReportingMarket6 ScorecardTemplatesStores Selling YTD.csv"
Dim mStrData As Worksheet
Dim mDataPaste As Worksheet
Set mStrData = Workbooks("Stores Selling YTD.csv").Worksheets("Stores Selling YTD")
Set mDataPaste = Workbooks("KROGER M6 SCORECARD TEMPLATE.xlsm").Worksheets("stores selling summary")
Dim mTemplateLastRow As Long
Dim mCopyLastRow As Long
mTemplateLastRow = mDataPaste.Cells(mDataPaste.Rows.Count, "B").End(xlUp).Offset(1).Row
mCopyLastRow = mStrData.Cells(mStrData.Rows.Count, "A").End(xlUp).Row
mStrData.Range("A13:B" & mCopyLastRow).Copy mDataPaste.Range("B" & mTemplateLastRow)
mStrData.Range("C13:C" & mCopyLastRow).Copy mDataPaste.Range("G" & mTemplateLastRow)
mStrData.Range("F13:I" & mCopyLastRow).Copy mDataPaste.Range("I" & mTemplateLastRow)
mStrData.Range("D13:E" & mCopyLastRow).Copy mDataPaste.Range("M" & mTemplateLastRow)
'Add Dates
Dim mTemplateLastRowb As Long
Dim mTemplateLastRowc As Long
mTemplateLastRowb = mDataPaste.Cells(mDataPaste.Rows.Count, "B").End(xlUp).Row
mTemplateLastRowc = mDataPaste.Cells(mDataPaste.Rows.Count, "B").End(xlUp).Offset(1).Row
Dim mFirstRow As Range
Dim mLastRow As Range
Set mFirstRow = Workbooks("KROGER M6 SCORECARD TEMPLATE.xlsm").Worksheets("stores selling summary").Range("A" & lTemplateLastRowc)
Set mLastRow = Workbooks("KROGER M6 SCORECARD TEMPLATE.xlsm").Worksheets("stores selling summary").Range("A" & mTemplateLastRowb)
Range(mFirstRow, mLastRow).Formula = "=concatenate(""Kroger YTD - Ending "",left(right('Weekly Division'!$A$4,24),23))"
'Add Attributes where possible
Dim nFirstRow As Range
Dim nLastRow As Range
Set nFirstRow = Workbooks("KROGER M6 SCORECARD TEMPLATE.xlsm").Worksheets("stores selling summary").Range("D6")
Set nLastRow = Workbooks("KROGER M6 SCORECARD TEMPLATE.xlsm").Worksheets("stores selling summary").Range("F" & mTemplateLastRowb)
Range(nFirstRow, nLastRow).Formula = "=INDEX(COMBINED!$C:$F,MATCH($C6,COMBINED!$H:$H,0),MATCH(D$5,COMBINED!$C$4:$F$4,0))"
Workbooks("Stores Selling YTD.csv").Close SaveChanges:=False
'Calculate Workbook
Calculate
'Paste Values
Workbooks("KROGER M6 SCORECARD TEMPLATE.xlsm").Worksheets("COMBINED").Range("A5:U" & gTemplateLastRowb).Copy
Workbooks("KROGER M6 SCORECARD TEMPLATE.xlsm").Worksheets("COMBINED").Range("A5:U" & gTemplateLastRowb).PasteSpecial Paste:=xlPasteValues
Workbooks("KROGER M6 SCORECARD TEMPLATE.xlsm").Worksheets("stores selling summary").Range("A5:N" & mTemplateLastRowb).Copy
Workbooks("KROGER M6 SCORECARD TEMPLATE.xlsm").Worksheets("stores selling summary").Range("A5:N" & mTemplateLastRowb).PasteSpecial Paste:=xlPasteValues
Application.CutCopyMode = False
'Save File as Template File
ActiveWorkbook.Save
'Turn on Screen Updates
Application.ScreenUpdating = True
Application.DisplayAlerts = True
Application.Calculation = xlCalculationAutomatic
End Sub
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP