Hi,
I am trying to put together some code to do the following
1. Open OLDDATA workbook (using the dialog box, file name and path will be different every time)
2. Copy all rows except row1 from OLDDATA, olddatasheet (this is the only worksheet in the file) to the workbook that the macro was run from (workbook=NEWDATA, sheet=newdatasheet. this will always be called the same). newdatasheet will already have data so i need it to copy to the next available row
3. Close OLDDATA workbook without saving
Can anyone help? my attempt is below...
![]()
' copy_new_forecasts Macro ' 'open OLDDATA Application.Dialogs(xlDialogOpen).Show Dim wbTarget As Workbook 'workbook where the data is to be pasted (NEWDATA, newdatasheet) Dim wbThis As Workbook 'workbook from where the data is to be copied (OLDDATA, olddatasheet) Dim strName As String 'name of the source sheet/ target workbook (olddatasheet) 'set to the current active workbook (OLDDATA) Set wbThis = ActiveWorkbook 'get the active sheetname of the book (olddatasheet) strName = ActiveSheet.Name 'set target workbook Set wbTarget = Workbooks("NEWDATA").Sheets("newdatasheet") 'activate the OLDDATA book wbThis.Activate 'copy the range from OLDDATA(all rows except row1, number of rows with data will be varied each time) wbThis.Range("???????").Copy 'paste the data on the next available row of NEWDATA, newdatasheet wbTarget.Range("A1").Range("A" & Rows.Count).End(xlUp).Offset(1, 0).PasteSpecial Paste:=xlPasteValues Application.CutCopyMode = False 'close the OLDDATA workbook wbThis.Close
Bookmarks