Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
Me Me is offline
external usenet poster
 
Posts: 67
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 91
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How copy none excel data & paste in 2007 without overwriting data Wakefootin Excel Discussion (Misc queries) 2 October 8th 09 12:15 AM
How to paste rows in 2007 without overwriting data? GAMEnt User Excel Discussion (Misc queries) 4 September 29th 07 11:06 PM
How to add data into a text file without overwriting existing data J@Y Excel Programming 2 June 28th 07 03:10 PM
loop through a column on a workbook copying data on each row to another workbook, then copy data back to the original workbook burl_rfc Excel Programming 1 April 1st 06 08:48 PM
updating of data without overwriting the previous data updated teyhuiyi Excel Programming 0 April 7th 04 03:40 AM


All times are GMT +1. The time now is 11:29 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"