Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Adding rows from sheets to one sheet

Okay, I am a newbie at Excel code, so please be patient with me. I am
looking at a way of taking all xls files in one folder, copying the second
row from each sheet and pasting it into a template that's already opened. I
won't know the name of the files in the folder, just that they will end in
xls and that only the second row will need to be copied (I think it will go
up to the 230th column) into the template, starting in the second row and
continuing on down the sheet until all are copied into this one file. I am
pretty sure this will involve a looping process, but I am not sure how to
programmatically accomplish this.

TIA,
Jason
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 72
Default Adding rows from sheets to one sheet

Try this, I didn't test it so there might be some trouble shooting
involved. Also, I have "C:\My docs" hard coded as the location of your
xls files, and Book1 as the name of your template.

Sub Macro2()
Dim Filename As String, Book1row As Integer
Filename = Dir("C:\My docs\" & "*.xls")
Book1row = 1
Do While myname < ""
Workbooks.Open Filename:="C:\My docs\" & Filename
Rows("2:2").Copy
Windows("Book1").Activate
Range("A" & Book1row).Select
ActiveSheet.Paste
Windows(Filename).Close
Book1row = Book1row + 1
myname = Dir
Loop
End Sub


*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Adding rows from sheets to one sheet

Claud,

Thanks very much. Well, when I ran the code I didn't get any errors, but
nothing happened either. Here is what I have:
ublic Sub CombineFiles()
Dim Filename As String, Book1row As Integer
Filename = Dir("C:\BRPT Files\" & "*.xls")
Book1row = 1
Do While myname < ""
Workbooks.Open Filename:="C:\BRPT Files\" & Filename
Rows("2:2").Copy
Windows("Comment1").Activate
Range("A" & Book1row).Select
ActiveSheet.Paste
Windows(Filename).Close
Book1row = Book1row + 1
myname = Dir
Loop
End Sub

Just a few notes: The excel sheet (Comment1.xls) I want everything pasted
into will be open during this process. The files that need to be open and
copied from are located in the C:\BRPT Files\ directory.

Thanks again for your help.

-Jason

"Claud Balls" wrote:

Try this, I didn't test it so there might be some trouble shooting
involved. Also, I have "C:\My docs" hard coded as the location of your
xls files, and Book1 as the name of your template.

Sub Macro2()
Dim Filename As String, Book1row As Integer
Filename = Dir("C:\My docs\" & "*.xls")
Book1row = 1
Do While myname < ""
Workbooks.Open Filename:="C:\My docs\" & Filename
Rows("2:2").Copy
Windows("Book1").Activate
Range("A" & Book1row).Select
ActiveSheet.Paste
Windows(Filename).Close
Book1row = Book1row + 1
myname = Dir
Loop
End Sub


*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 72
Default Adding rows from sheets to one sheet

Made a mistake, put the Filename variable where the myname variable is
at.



*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
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
Linked sheets, blank cells and adding new rows CharlieJane Excel Worksheet Functions 1 July 25th 08 07:12 PM
adding sheets based upon a template sheet [email protected] Excel Worksheet Functions 1 December 7th 07 05:03 PM
Adding rows to tables in 2 different sheets birdpants Excel Discussion (Misc queries) 1 August 7th 07 11:40 AM
SIMULTANEOUSLY adding rows in two sheets Radoslav Radev Excel Programming 4 December 8th 04 01:55 PM
How to control sheet number when adding and deleting sheets? ChuckM[_2_] Excel Programming 0 January 28th 04 05:52 PM


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