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

Kindly help me on this..

I have 25 excel sheets saves in my C drive...

I wish to copy column z from first excel sheet & paste it col A of the new
sheet.
Then
I wish to copy column z from second excel sheet & paste it col B of the new
sheet.
Then
Col z of third sheet in Col C of new sheet

So on so forth till i fiinish my last 25th sheet.

This is something we can do manually but if we can do it using macro it
would be great.

Thanks a lot for help in advance..

Boss

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default Add data from several excel sheets into one

try this code. The code is copying Column A of each worksheet. You may need
to make minor changes. Also change the Folder to the appropriate folder.

Sub test()

Const ForReading = 1, ForWriting = 2, ForAppending = 3
Folder = "C:\temp\test"
Const TristateUseDefault = -2, TristateTrue = -1, TristateFalse = 0

Folder = "C:\temp\test"

Set fsread = CreateObject("Scripting.FileSystemObject")
Colcount = 1
First = True
Do
If First = True Then
Filename = Dir(Folder & "\*.xls")
First = False
Else
Filename = Dir()
End If
If Filename < "" Then
'open files
Workbooks.Open Filename:=Folder & "\" & Filename
ActiveWorkbook.ActiveSheet.Columns("A:A").Copy _
Destination:=ThisWorkbook.ActiveSheet.Columns(Colc ount)
Colcount = Colcount + 1
ActiveWorkbook.Close
End If
Loop While Filename < ""


End Sub

"Boss" wrote:

Kindly help me on this..

I have 25 excel sheets saves in my C drive...

I wish to copy column z from first excel sheet & paste it col A of the new
sheet.
Then
I wish to copy column z from second excel sheet & paste it col B of the new
sheet.
Then
Col z of third sheet in Col C of new sheet

So on so forth till i fiinish my last 25th sheet.

This is something we can do manually but if we can do it using macro it
would be great.

Thanks a lot for help in advance..

Boss

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 123
Default Add data from several excel sheets into one

This was awesome..

Thanks, Thanks a lot for your help..

Boss

"Joel" wrote:

try this code. The code is copying Column A of each worksheet. You may need
to make minor changes. Also change the Folder to the appropriate folder.

Sub test()

Const ForReading = 1, ForWriting = 2, ForAppending = 3
Folder = "C:\temp\test"
Const TristateUseDefault = -2, TristateTrue = -1, TristateFalse = 0

Folder = "C:\temp\test"

Set fsread = CreateObject("Scripting.FileSystemObject")
Colcount = 1
First = True
Do
If First = True Then
Filename = Dir(Folder & "\*.xls")
First = False
Else
Filename = Dir()
End If
If Filename < "" Then
'open files
Workbooks.Open Filename:=Folder & "\" & Filename
ActiveWorkbook.ActiveSheet.Columns("A:A").Copy _
Destination:=ThisWorkbook.ActiveSheet.Columns(Colc ount)
Colcount = Colcount + 1
ActiveWorkbook.Close
End If
Loop While Filename < ""


End Sub

"Boss" wrote:

Kindly help me on this..

I have 25 excel sheets saves in my C drive...

I wish to copy column z from first excel sheet & paste it col A of the new
sheet.
Then
I wish to copy column z from second excel sheet & paste it col B of the new
sheet.
Then
Col z of third sheet in Col C of new sheet

So on so forth till i fiinish my last 25th sheet.

This is something we can do manually but if we can do it using macro it
would be great.

Thanks a lot for help in advance..

Boss

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 to update data from multiple sheets to one specific sheets Khawajaanwar Excel Discussion (Misc queries) 4 January 15th 10 07:31 AM
Merging data from 2 data excel sheets Joe Excel Discussion (Misc queries) 2 November 3rd 09 01:08 PM
Multiple Sheets (Need to create 500 individual sheets in one workbook, pulling DATA Amaxwell Excel Worksheet Functions 4 August 17th 06 06:23 AM
Excel data across sheets Bee Excel Discussion (Misc queries) 3 April 1st 06 11:31 AM
In 3 active sheets in wkbk, determine& display the # of sheets that have data wrpalmer Excel Discussion (Misc queries) 1 November 4th 05 02:01 PM


All times are GMT +1. The time now is 08:12 AM.

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"