Xcelnewbie
New Member
A friend of mine created dump file where all the data saved from individual trackers will be stored automatically. However, i noticed that there are times when the data being transferred/saved to the dump file gets replicated 4 times. So even if we only hit the "save" button in the individual tracker ones, 4 data will be saved in the dump. Below is the code my friend gave me...please check and let me know what must be removed.
Code:
Sub DumpFiles()
Application.ScreenUpdating = False
Application.DisplayAlerts = False
Dim ws As Worksheet
Dim Dws As Worksheet
Set ws = Sheets("Raw Data")
Dim lrow As Long
Dim Dlrow As Long ''used for the dump sheet
''''
''last row in users worksheet
''We will in this test copy the second row( not the header row )
''' to the last row up to Column L'
''' the last row code
lrow = ws.Range("B65536").End(xlUp).Row '''for the users list
''' now copy the data to the dump sheet ''
'' we also need to know the row to copy the data to in the Dump sheet
'' Need to make sure Dump Workbook is open ''
''' You need to change to the actual dump file
'' You also need to change the file path
If Not WorkbookOpen("Productivity Tracker Dump.xlsm") Then
''''''''''''''''' This is my path need to update to yours '''
Application.Workbooks.Open("\\Desktop\Productivity Tracker Dump.xlsm", UpdateLinks:=3) _
.Activate
Else
Workbooks("Productivity Tracker Dump.xlsm").Activate
End If
Set Dws = Workbooks("Productivity Tracker Dump.xlsm").Sheets("Raw Data")
Dlrow = Dws.Range("B65536").End(xlUp).Row + 1 ''we add 1 because its the next empty row
'' this should copy the data
ws.Range("A6:m" & lrow).Copy Destination:=Dws.Range("A" & Dlrow)
'' Now we are done ''
ActiveWorkbook.Close savechanges:=True ''we close the shared workbook and save changes
Application.ScreenUpdating = True
Application.DisplayAlerts = True
End Sub
Function WorkbookOpen(WorkBookName As String) As Boolean
' returns TRUE if the workbook is open
WorkbookOpen = False
On Error Goto WorkBookNotOpen
If Len(Application.Workbooks(WorkBookName).Name) > 0 Then
WorkbookOpen = True
Exit Function
End If
WorkBookNotOpen:
End Function