Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default how do import data from two sheets into one


I'm trying to figure out the easiest way to do this.
I want two copy a set of data from two different workbooks and merge it

together into one workbook.

Book1 Data1
Book2 Data2


Merge book1 and book2 into book3.

I've created a button in book3 to pull the data from book1 and book2.
I've tried several different ways but it's a bit messy. I was wondering
if there is a simple code for it.

thanks!


--
vbidiot
------------------------------------------------------------------------
vbidiot's Profile: http://www.excelforum.com/member.php...o&userid=31582
View this thread: http://www.excelforum.com/showthread...hreadid=515530

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 94
Default how do import data from two sheets into one

Try to code below. Note that:
1) The macro will clear the cells in the target worksheet first (in book3)
2) I assume the 2 data lists have the same columns
3) The macro expects the 2 data lists have the same column headings, and it
will only copy the column headings of the 1st data list.


Sub copy_data()
Dim tmp As Single
Dim target_sheet As Object
Set target_sheet = ThisWorkbook.Worksheets("Sheet1")
target_sheet.Cells.Clear
Workbooks("Book1").Worksheets("Sheet1").Range("A1" ).CurrentRegion.Copy _
target_sheet.Range("A1")
tmp = target_sheet.Range("A1").CurrentRegion.Rows.Count
With Workbooks("Book2").Worksheets("Sheet1").Range("A1" ).CurrentRegion
.Offset(1, 0).Resize(.Rows.Count - 1, .Columns.Count).Copy _
target_sheet.Range("A1").Range("A1").Offset(tmp, 0)
End With
End Sub


Regards,
Edwin Tam

http://www.vonixx.com


"vbidiot" wrote:


I'm trying to figure out the easiest way to do this.
I want two copy a set of data from two different workbooks and merge it

together into one workbook.

Book1 Data1
Book2 Data2


Merge book1 and book2 into book3.

I've created a button in book3 to pull the data from book1 and book2.
I've tried several different ways but it's a bit messy. I was wondering
if there is a simple code for it.

thanks!


--
vbidiot
------------------------------------------------------------------------
vbidiot's Profile: http://www.excelforum.com/member.php...o&userid=31582
View this thread: http://www.excelforum.com/showthread...hreadid=515530


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default how do import data from two sheets into one


I keep getting an error message but I think it is because of how I'm
putting in the files to pull.

my book 1 is P:/project/table
my book 2 is P:/project/table2

What am I doing wrong??

the file that I want to pull to is:

p:/import


--
vbidiot
------------------------------------------------------------------------
vbidiot's Profile: http://www.excelforum.com/member.php...o&userid=31582
View this thread: http://www.excelforum.com/showthread...hreadid=515530

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
Import sheets Chi Excel Discussion (Misc queries) 2 December 16th 09 06:58 PM
Import data from a particular cell in different excel sheets Sri Harsha[_2_] Excel Discussion (Misc queries) 1 September 8th 09 01:03 PM
How to Start Excel in Text Import Wizard for data import rlelvis Setting up and Configuration of Excel 0 July 10th 08 08:40 PM
how do i use import to consolidate data from multiple sheets Naveen Excel Worksheet Functions 1 April 14th 06 12:41 PM
Import data into seperate sheets CPower[_23_] Excel Programming 8 July 22nd 04 01:14 PM


All times are GMT +1. The time now is 07:05 AM.

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

About Us

"It's about Microsoft Excel"