I am trying to put togher a macro that will copy a range from a workbook and add it to a history report that will store the data. I want the code to add the data to the next row down and leave the previous data the way it was. However I am stuck and am getting a complie error on this part of the code:
Here is the full code:DestBook.Worksheets(1).Range("A" & Rows.Count).End(xlUp)(2, 1)
I am still learning vba and having a hard time with thisSub CopyData() Dim DestBook As Workbook, SrcBook As Workbook Application.ScreenUpdating = False Set SrcBook = ThisWorkbook On Error Resume Next Set DestBook = Workbooks.Open("I:\sctest.xls") SrcBook.Worksheets(1).Range("A1:F1").Copy Application.CutCopyMode = False DestBook.Worksheets(1).Range("A" & Rows.Count).End(xlUp)(2, 1) Application.CutCopyMode = False DestBook.Save DestBook.Close End If On Error GoTo 0 Set DestBook = Nothing Set SrcBook = Nothing End Sub
Any help would be wonderful.
That bit of code describes a cell, but it doesn't say what to do with it.
Perhaps
DestBook.Worksheets(1).Range("A" & Rows.Count).End(xlUp)(2, 1).Paste
_
...How to Cross-post politely...
..Wrap code by selecting the code and clicking the # or read this. Thank you.
Wow I can't believe i missed that. thanks.
That wasn't working either. I tried playing with it for a while and now i'm getting an
Object doesn't support this property or method on the same line.
This is what the code looks like right now:
Sub CopyData() Dim DestBook As Workbook, SrcBook As Workbook Application.ScreenUpdating = False Set SrcBook = ThisWorkbook SrcBook.Sheets(1).Range("A1:F1").Copy Set DestBook = Workbooks.Open("I:\sctest.xls") DestBook.Sheets(1).Range("A" & Rows.Count).End(xlUp)(2, 1).Paste Application.CutCopyMode = False DestBook.Save DestBook.Close End Sub
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks