PDA

View Full Version : Excel VBA to cut & paste between worksheets



PeterNZ
12-27-2009, 03:46 PM
Hi I'm using Excel 2003 with VBA at work to do a small project.
Ive created userform to enter 10 fields of data into a spreeddheet(named CalloutLog) Using comboboxs textboxs etc. That all works really well all of the entries appear in the spreedsheet "CalloutLog" .

Now I would like to have a commandbutton on "CalloutLog" so when all the entries have been made for that week. The button can be clicked and all of those entries are cut and pasted (or otherwise transferred) appended to the bottom of a worksheet named MasterCalloutLog in another workbook (note must not overwrite exiting MasterCalloutLog data) and a messagebox to popup and inform the user that the data has been transferred successfully.

So CalloutLog sheet that the person entered the data into originally is now blank except for the header row and all the data now resides in the MasterCalloutLog. Where our engineer can make his pretty charts from it.:bow:

Thakyou

Bob Phillips
12-27-2009, 04:32 PM
Something like this?



Dim LastRow As Long
Dim NextRow As Long

With Worksheets("MasterCalloutLog")

NextRow = .Cells(.Rows.Count, "A").End(xlUp).Row + 1
End With

With Worksheets("CalloutLog")

LastRow = .Cells(.Rows.Count, "A").End(xlUp).Row
.Rows(2).Resize(LastRow -1).Copy Worksheets("MasterCalloutLog").Cells(NextRow, "A")
End With