Hello,
I use this code to upload data to another workbook on a server. But I need some help with adjustments.
I do not want the data in target workbook to be replaced, I want to add new data the last available row in the target workbook.
I would appreciate the help a lot
!
Sub CopyOpenItems()
'
' CopyOpenItems Macro
' Copy open items to sheet.
'
' Keyboard Shortcut: Ctrl+Shift+O
'
Dim wbTarget As Workbook 'workbook where the data is to be pasted
Dim wbThis As Workbook 'workbook from where the data is to copied
Dim strName As String 'name of the source sheet/ target workbook
Dim wbSource As Worksheet
Application.ScreenUpdating = False
'set to the current active workbook (the source book)
Set wbThis = ActiveWorkbook
'get the active sheetname of the book
strName = ActiveSheet.Name
'open a workbook that has same name as the sheet name
Set wbTarget = Workbooks.Open("P:\SE\AVK\C. Projektmodell\Caj Pärmen Utveckling\Databas.xlsx")
'select cell A1 on the target book
wbTarget.Sheets("Databas").Range("A1").Select
'clear existing values form target book
wbTarget.Sheets("Databas").Range("A1:L2000").ClearContents
'activate the source book
wbThis.Activate
'clear any thing on clipboard to maximize available memory
Application.CutCopyMode = False
'copy the range from source book
wbThis.Sheets("Databas").Range("A2:L2000").Copy
'paste the data on the target book
wbTarget.Sheets("Databas").Range("A1").PasteSpecial
'clear any thing on clipboard to maximize available memory
Application.CutCopyMode = False
'save the target book
wbTarget.Save
'close the workbook
wbTarget.Close
'activate the source book again
wbThis.Activate
'clear memory
Set wbTarget = Nothing
Set wbThis = Nothing
Application.ScreenUpdating = True
End Sub
Bookmarks