Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default help please! need a macro which can combine data from 2 excel sheets

I have an excel file with some data till row 50.(can be more or less)
and another excel file with data till row 100 (can be more or less)

what i want is that i get a macro which automatically adds the data
from second sheet below the data in sheet 1.

the data in first file can end on row 50 or 60 or at any row

thank u so much

any ideas


and i have to combine more 30 files like these into that first file.


---
Message posted from http://www.ExcelForum.com/

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default help please! need a macro which can combine data from 2 excel sheets

Hi vikram

Try this example
http://www.rondebruin.nl/copy2.htm

--
Regards Ron de Bruin
http://www.rondebruin.nl


"vikram " wrote in message ...
I have an excel file with some data till row 50.(can be more or less)
and another excel file with data till row 100 (can be more or less)

what i want is that i get a macro which automatically adds the data
from second sheet below the data in sheet 1.

the data in first file can end on row 50 or 60 or at any row

thank u so much

any ideas


and i have to combine more 30 files like these into that first file.


---
Message posted from http://www.ExcelForum.com/



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 49
Default help please! need a macro which can combine data from 2 excel sheets

As long as there are no spaces you can use .end eg

Range("A2").End(xlDown).Offset(1, 0).Select

will give you the equivalent of selecting A2 then pressing Ctrl+down arrow,
then pressing down again - taking you to the next available cell. You can
then copy and paste from your files into the sheet. Some kind of loop would
help, going through each file, opening, copying, pasting in your workbook,
closing then moving down as above before repeating.

Sorry it's a bit vague, but I think you get the idea :)

Jeff

"vikram " wrote in message
...
I have an excel file with some data till row 50.(can be more or less)
and another excel file with data till row 100 (can be more or less)

what i want is that i get a macro which automatically adds the data
from second sheet below the data in sheet 1.

the data in first file can end on row 50 or 60 or at any row

thank u so much

any ideas


and i have to combine more 30 files like these into that first file.


---
Message posted from http://www.ExcelForum.com/



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default help please! need a macro which can combine data from 2 excel sheets

hello Jeff! I need a macro which can combine data from 2 differen
workbooks and not 2 different sheets from 1 workbook!

thank

--
Message posted from http://www.ExcelForum.com

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 49
Default help please! need a macro which can combine data from 2 excel sheets

Try a bit of code that does something like this:

ThisWorkbook.Sheets("Masterlist").Range("a2").Sele ct
For intCycle = 1 To 30 ' number of files here
ThisWorkbook.Sheets("Masterlist").Range("a2").End( xlDown).Offset(1,
0).Select
strFilename = Sheets("filelist").Range("a" & intCycle).Value
Workbooks.Open ("C:\Temp" & strFilename & ".xls")
Sheets("list").Range("a1").Select ' you can change this based on the
sheet in the individual files
Range(Selection, Selection.End(xlDown)).Copy
ThisWorkbook.Sheets("Masterlist").Select
ActiveSheet.Paste
Workbooks(strFilename).Close (False)
ThisWorkbook.Sheets("Masterlist").Range("a2").End( xlDown).Offset(1,
0).Select
Next intCycle

You need a sheet with the list of files on it from A1 downwards called
filelist, and a sheet called Master list where all the data will be copied
into. I think that will work.

Jeff

"vikram " wrote in message
...
hello Jeff! I need a macro which can combine data from 2 different
workbooks and not 2 different sheets from 1 workbook!

thanks


---
Message posted from http://www.ExcelForum.com/





  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default help please! need a macro which can combine data from 2 excel sheets

Try this then
http://www.rondebruin.nl/copy3.htm

--
Regards Ron de Bruin
http://www.rondebruin.nl


"vikram " wrote in message ...
hello Jeff! I need a macro which can combine data from 2 different
workbooks and not 2 different sheets from 1 workbook!

thanks


---
Message posted from http://www.ExcelForum.com/



  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default help please! need a macro which can combine data from 2 excel sheets

Hi

You Could use this


Code
-------------------

Sub CopySheets()
Dim Wks As Worksheet
Dim rng As Range
Dim NumberofSheets As Integer
Dim I As Integer

'Set variables
Set Wks = ActiveSheet
Set rng = Wks.Range("A" & Range("A" & Rows.Count).End(xlUp).Row + 1)
NumberofSheets = Worksheets.Count

'copy the data accross and change the initial paste cell
For I = 2 To NumberofSheets
Worksheets(I).UsedRange.Copy Destination:=rng
Set rng = Wks.Range("A" & Range("A" & Rows.Count).End(xlUp).Row + 1)
Next I

End Sub

-------------------


with the sheet you are copying to as the first sheet of the curren
workbook.

HTH

Davi

--
Message posted from http://www.ExcelForum.com

  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default help please! need a macro which can combine data from 2 excel sheets

thank u.....worked amazingl

--
Message posted from http://www.ExcelForum.com

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
Combine 2 sheets into 1 that will update w/new data Ms. Von Excel Worksheet Functions 2 June 23rd 08 04:12 PM
How do I combine data from several sheets into one main sheet? Caren F Excel Worksheet Functions 0 April 19th 06 06:39 PM
combine data from multiple sheets Roxypup Excel Discussion (Misc queries) 2 April 7th 06 07:40 AM
How do I combine and match data from 2 sheets CathyW Excel Discussion (Misc queries) 3 March 23rd 06 10:18 PM
How to append/combine (not add) data in several sheets into one? ParkCrescent Excel Discussion (Misc queries) 2 August 15th 05 01:28 PM


All times are GMT +1. The time now is 07:09 PM.

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"