Home |
Search |
Today's Posts |
|
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Paste data into another workbook but not overwriting original data
Afternoon all,
Im trying to programmatically copy and paste from one workbook into another, with two seperate bits of data pulled from seperate locations. So i have an excel file with two tabs of data, i then want to copy and paste the data and have them both end up in one sheet. Hope that makes sense. Thanks |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Paste data into another workbook but not overwriting originaldata
On Dec 13, 8:37 am, Me wrote:
Afternoon all, Im trying to programmatically copy and paste from one workbook into another, with two seperate bits of data pulled from seperate locations. So i have an excel file with two tabs of data, i then want to copy and paste the data and have them both end up in one sheet. Hope that makes sense. Thanks Sounds like you have two workbooks, one with two tabs (the source workbook) containing the info you want to copy and another (the destination workbook) where you want the data to end up. Just reference each workbook, copy the elements from the source and then paste them into the destination. Here's a most basic example of copying items in cell A1 of sheets 1 and 2 and then pasting them into another workbook into cell A1 and B1 of sheet 1: Private Sub Merge() Dim s1 As String, s2 As String Dim sD As String 'name of destination book Dim wbS As Workbook 'source book Dim wbD As Workbook 'destination book 'set the name of the destination workbook sD = "yourbook.xls" 'get the workbook objects Set wbS = ActiveWorkbook Set wbD = Workbooks(sD) 'get the values from the source s1 = wbS.Sheets(1).Range("A1").Value s2 = wbS.Sheets(1).Range("A1").Value 'place the values in the destination wbD.Sheets(1).Range("A1").Value = s1 wbD.Sheets(1).Range("B1").Value = s2 'clean up Set wbS = Nothing Set wbD = Nothing End Sub Hope that's what you were needing Cory |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
How copy none excel data & paste in 2007 without overwriting data | Excel Discussion (Misc queries) | |||
How to paste rows in 2007 without overwriting data? | Excel Discussion (Misc queries) | |||
How to add data into a text file without overwriting existing data | Excel Programming | |||
loop through a column on a workbook copying data on each row to another workbook, then copy data back to the original workbook | Excel Programming | |||
updating of data without overwriting the previous data updated | Excel Programming |