Hi there,
I am new at VBA and I am working on my first project.
I have several detailed workbooks from which I want to copy a certain table to a central workbook.
Below is part of the code that I have written.
The problem that I encounter is that the code does not append to the bottom of the table in the central workbook, but overwrites the already existing data. What am I not doing correctly?
The code is run from the central workbook and runs through the several detailed workbooks.
The code is the part where I open a detailed workbook and append the contents of the table "TableFcstDetails" in the detailed workbook into the table "TableFcstCentral" in the central workbook.
'If Forecast Details Workbook Status = "Submitted" and Forecast Details Workbook Process Status = "NOT Procssed"
'Then Append table "TableFcstDetails" from Detail workbook to table "TableFcstCentral" in Central workbook - values only
If TmpDtlsStts = "Submitted" And TmpDtlsPrcssStts = "NOT Processed" Then
TmpCntrlFile = TmpPath & "Forecast - Central - 2013-04-20 VBA MASTER.xlsm"
TmpPathFile = TmpPath & TmpFile
Dim sWb As Workbook
Dim dWb As Workbook
Dim sWs As Worksheet
Dim dWs As Worksheet
Dim sLo As ListObject
Dim dLo As ListObject
Dim sRng, dRng As Range
Set dWb = ThisWorkbook
Set dWs = dWb.Worksheets("Central")
Set dLo = dWs.ListObjects("TableFcstCentral")
Set dRng = dLo.HeaderRowRange.Columns(1).Offset(dLo.ListRows.Count + 1, 0)
'Open Detail workbook
Workbooks.Open Filename:=TmpPathFile
Set sWb = Workbooks(TmpFile)
Set sWs = sWb.Worksheets("Details")
Set sLo = sWs.ListObjects("TableFcstDetails")
Set sRng = sLo.DataBodyRange
sRng.PasteSpecial
dRng.PasteSpecial Paste:=xlPasteValues
Application.CutCopyMode = False
'Update Forecast Details Workbook Process Status to "Processed"
'***Forecast Details Workbook Process Status is in Details worbook worksheet "Local Master Data" cell B17
Workbooks(TmpFile).Sheets("Local Master Data").Range("B17").Value = "Processed"
'Close Detail workbook
Workbooks(TmpFile).Save
Workbooks(TmpFile).Close False
Worksheets("Processing Status").Activate
Application.CutCopyMode = False
Any help will be highly appreciated!
Bookmarks