#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default simple code

Dear microsoft.public.excel.programming,
I have about 50 files each with 30 sheets. Files are all similarly named
e.g. File112008-01, File122008-01 etc. and all sheets are named as dates
(e.g. first sheet is 11.01.2008, second is 11.02.2008 etc.), I'd like to
copy all E columns from all the sheets from all the files on one sheet,
column by column (after all place is taken, that it goes to another sheet).
How can I easily solve this? (I recently started to learn how to solve
easier problems with VBA but one this solution are some other problems I
have based, and I couldn't find myself how to solve it). I hope it's not too
much a newbish question in this group.
Thank you in advance

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default simple code

change Folder as necessary

Sub Getfiles()


Folder = "C:\temp\"
Set DestSht = ThisWorkbook.Sheets("Sheet1")


FName = Dir(Folder & "*.xls")
Do While FName < ""
Set Bk = Workbooks.Open(Filename:=Folder & FName)
For Each Sht In Bk.Sheets
LastRow = Sht.Range("E" & Rows.Count).End(xlUp).Row

If DestSht.Range("A1") = "" Then
NewRow = 1
Else
NewRow = DestSht.Range("A" & Rows.Count).End(xlUp).Row + 1
End If

DestSht.Range("A" & NewRow & ":A" & (NewRow + LastRow - 1)) = _
FName

DestSht.Range("B" & NewRow & ":B" & (NewRow + LastRow - 1)) = _
Sht.Name

Sht.Range("E1:E" & LastRow).Copy _
Destination:=DestSht.Range("C" & NewRow)

Next Sht
Bk.Close savechanges:=False
FName = Dir()
Loop

End Sub


"small caps" wrote:

Dear microsoft.public.excel.programming,
I have about 50 files each with 30 sheets. Files are all similarly named
e.g. File112008-01, File122008-01 etc. and all sheets are named as dates
(e.g. first sheet is 11.01.2008, second is 11.02.2008 etc.), I'd like to
copy all E columns from all the sheets from all the files on one sheet,
column by column (after all place is taken, that it goes to another sheet).
How can I easily solve this? (I recently started to learn how to solve
easier problems with VBA but one this solution are some other problems I
have based, and I couldn't find myself how to solve it). I hope it's not too
much a newbish question in this group.
Thank you in advance


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,836
Default simple code

When you have some free time you may want to take a look at this:
http://www.rondebruin.nl/csv.htm

Excellent Batch Processing example he
http://www.rondebruin.nl/copy4.htm

Regards,
Ryan---

--
RyGuy


"Joel" wrote:

change Folder as necessary

Sub Getfiles()


Folder = "C:\temp\"
Set DestSht = ThisWorkbook.Sheets("Sheet1")


FName = Dir(Folder & "*.xls")
Do While FName < ""
Set Bk = Workbooks.Open(Filename:=Folder & FName)
For Each Sht In Bk.Sheets
LastRow = Sht.Range("E" & Rows.Count).End(xlUp).Row

If DestSht.Range("A1") = "" Then
NewRow = 1
Else
NewRow = DestSht.Range("A" & Rows.Count).End(xlUp).Row + 1
End If

DestSht.Range("A" & NewRow & ":A" & (NewRow + LastRow - 1)) = _
FName

DestSht.Range("B" & NewRow & ":B" & (NewRow + LastRow - 1)) = _
Sht.Name

Sht.Range("E1:E" & LastRow).Copy _
Destination:=DestSht.Range("C" & NewRow)

Next Sht
Bk.Close savechanges:=False
FName = Dir()
Loop

End Sub


"small caps" wrote:

Dear microsoft.public.excel.programming,
I have about 50 files each with 30 sheets. Files are all similarly named
e.g. File112008-01, File122008-01 etc. and all sheets are named as dates
(e.g. first sheet is 11.01.2008, second is 11.02.2008 etc.), I'd like to
copy all E columns from all the sheets from all the files on one sheet,
column by column (after all place is taken, that it goes to another sheet).
How can I easily solve this? (I recently started to learn how to solve
easier problems with VBA but one this solution are some other problems I
have based, and I couldn't find myself how to solve it). I hope it's not too
much a newbish question in this group.
Thank you in advance


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
Pivot Table Code - Simple Code Fix? J.W. Aldridge Excel Programming 2 April 4th 08 02:24 PM
Simple VB code cjupiter Excel Programming 3 January 25th 06 01:08 AM
Need code for simple IF-Then excelnut1954 Excel Programming 5 November 17th 05 08:23 PM
Want a simple VBA code. madhu Excel Programming 2 February 1st 05 01:46 PM
Simple For Each Next code Marek S. Excel Programming 0 July 28th 03 12:34 PM


All times are GMT +1. The time now is 12:15 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"