jimbogarner
Board Regular
- Joined
- Apr 22, 2010
- Messages
- 102
Hi,
Ive created a macro in a workbook that takes data from a tab 'Latest data' and adds it to another tab, however, the following month when that data gets replaced with the following months 'latest data', I want that macro to add the new data to the bottom of what was added before - it currently just overwrites what was there previously?
This is the macro that I recorded;
Sub Run_Rec()
'
' Run_Rec Macro
'
'
Sheets("Latest Data").Select
Range("A1").Select
Range(Selection, Selection.End(xlDown)).Select
Rows("1:59").Select
Selection.Copy
Sheets("B&G SAP DL").Select
ActiveWindow.SmallScroll Down:=15
Range("A70").Select
ActiveSheet.Paste
Range("F69").Select
Application.CutCopyMode = False
Selection.AutoFill Destination:=Range("F69:F128")
Range("F69:F128").Select
ActiveWindow.SmallScroll Down:=12
Range("J70").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Copy
Range("Q70").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
Selection.TextToColumns Destination:=Range("Q70"), DataType:=xlDelimited, _
TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=True, _
Semicolon:=False, Comma:=False, Space:=False, Other:=True, OtherChar _
:="-", FieldInfo:=Array(Array(1, 1), Array(2, 1), Array(3, 1)), _
TrailingMinusNumbers:=True
ActiveWindow.SmallScroll Down:=-12
Range("R70").Select
Sheets("B&G").Select
Range("B23").Select
ActiveSheet.PivotTables("PivotTable3").ChangePivotCache ActiveWorkbook. _
PivotCaches.Create(SourceType:=xlDatabase, SourceData:= _
"\\ni.ad.newsint\SharedData\Central\PetGroup\petcommon\PETERB\Wireless Group\9. Month End\FY22\6. December\B&G\BS Recs\[Accruals - B&G - Dec 21.xlsx]B&G SAP DL!R1C1:R128C19" _
, Version:=xlPivotTableVersion15)
Range("C19").Select
Calculate
Sheets("B&G SAP DL").Select
Range("F105").Select
Sheets("B&G").Select
Range("C22").Select
ActiveSheet.PivotTables("PivotTable3").PivotCache.Refresh
End Sub
Thanks,
James
Ive created a macro in a workbook that takes data from a tab 'Latest data' and adds it to another tab, however, the following month when that data gets replaced with the following months 'latest data', I want that macro to add the new data to the bottom of what was added before - it currently just overwrites what was there previously?
This is the macro that I recorded;
Sub Run_Rec()
'
' Run_Rec Macro
'
'
Sheets("Latest Data").Select
Range("A1").Select
Range(Selection, Selection.End(xlDown)).Select
Rows("1:59").Select
Selection.Copy
Sheets("B&G SAP DL").Select
ActiveWindow.SmallScroll Down:=15
Range("A70").Select
ActiveSheet.Paste
Range("F69").Select
Application.CutCopyMode = False
Selection.AutoFill Destination:=Range("F69:F128")
Range("F69:F128").Select
ActiveWindow.SmallScroll Down:=12
Range("J70").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Copy
Range("Q70").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
Selection.TextToColumns Destination:=Range("Q70"), DataType:=xlDelimited, _
TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=True, _
Semicolon:=False, Comma:=False, Space:=False, Other:=True, OtherChar _
:="-", FieldInfo:=Array(Array(1, 1), Array(2, 1), Array(3, 1)), _
TrailingMinusNumbers:=True
ActiveWindow.SmallScroll Down:=-12
Range("R70").Select
Sheets("B&G").Select
Range("B23").Select
ActiveSheet.PivotTables("PivotTable3").ChangePivotCache ActiveWorkbook. _
PivotCaches.Create(SourceType:=xlDatabase, SourceData:= _
"\\ni.ad.newsint\SharedData\Central\PetGroup\petcommon\PETERB\Wireless Group\9. Month End\FY22\6. December\B&G\BS Recs\[Accruals - B&G - Dec 21.xlsx]B&G SAP DL!R1C1:R128C19" _
, Version:=xlPivotTableVersion15)
Range("C19").Select
Calculate
Sheets("B&G SAP DL").Select
Range("F105").Select
Sheets("B&G").Select
Range("C22").Select
ActiveSheet.PivotTables("PivotTable3").PivotCache.Refresh
End Sub
Thanks,
James