Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default macro for opening all excel files and copying contents


could anyone help me write macro to open allexcel files from a folder
and copy certain rows and paste all details in a new excel sheet line
by line.


Thanks..


--
roshinpp_77
------------------------------------------------------------------------
roshinpp_77's Profile: http://www.excelforum.com/member.php...o&userid=34924
View this thread: http://www.excelforum.com/showthread...hreadid=546652

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default macro for opening all excel files and copying contents

Sub ConsolidateData()
Dim bk as Workbook, bk1 as Workbook
Dim sh as Worksheet
Dim sPath as String, sName as String
Dim rw as Long
sPath = "C:\Myfolder\"
sName = Dir(sPath & "*.xls")
set bk = ActiveWorkbook
set sh = bk.Worksheets.Add(After:=bk.Worksheets( _
bk.worksheets.count))
rw = 1
do while sName < ""
set bk1 = workbooks.open(sPath & sName)
bk1.worksheets(1).Range("1:5").copy sh.Cells(rw,1)
rw = rw + 5
bk1.close Savechanges:=False
sName = dir
Loop
End sub

should be pretty close to what you want. Adjust as appropriate

--
Regards,
Tom Ogilvy



"roshinpp_77" wrote:


could anyone help me write macro to open allexcel files from a folder
and copy certain rows and paste all details in a new excel sheet line
by line.


Thanks..


--
roshinpp_77
------------------------------------------------------------------------
roshinpp_77's Profile: http://www.excelforum.com/member.php...o&userid=34924
View this thread: http://www.excelforum.com/showthread...hreadid=546652


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default macro for opening all excel files and copying contents


Thanks Tom ..this was really helpfull..now i can modify as per my
requirement..

Tom Ogilvy Wrote:
Sub ConsolidateData()
Dim bk as Workbook, bk1 as Workbook
Dim sh as Worksheet
Dim sPath as String, sName as String
Dim rw as Long
sPath = "C:\Myfolder\"
sName = Dir(sPath & "*.xls")
set bk = ActiveWorkbook
set sh = bk.Worksheets.Add(After:=bk.Worksheets( _
bk.worksheets.count))
rw = 1
do while sName < ""
set bk1 = workbooks.open(sPath & sName)
bk1.worksheets(1).Range("1:5").copy sh.Cells(rw,1)
rw = rw + 5
bk1.close Savechanges:=False
sName = dir
Loop
End sub

should be pretty close to what you want. Adjust as appropriate

--
Regards,
Tom Ogilvy



"roshinpp_77" wrote:


could anyone help me write macro to open allexcel files from a

folder
and copy certain rows and paste all details in a new excel sheet

line
by line.


Thanks..


--
roshinpp_77

------------------------------------------------------------------------
roshinpp_77's Profile:

http://www.excelforum.com/member.php...o&userid=34924
View this thread:

http://www.excelforum.com/showthread...hreadid=546652




--
roshinpp_77
------------------------------------------------------------------------
roshinpp_77's Profile: http://www.excelforum.com/member.php...o&userid=34924
View this thread: http://www.excelforum.com/showthread...hreadid=546652

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
Opening Files - Macro Max2073 Excel Worksheet Functions 1 December 10th 09 06:06 AM
Macro copying info/data in multiple excel files into one summary file. Jskasango Excel Programming 10 April 6th 06 08:27 AM
Macro for opening new files and copying from them - please help! Mary T Excel Programming 6 January 6th 06 08:50 PM
Opening Multiple files and Copying the info all to one other sheet MsLucy Excel Discussion (Misc queries) 2 January 6th 06 05:41 PM
Copying Excel files and Macro problems No Name Excel Programming 1 April 5th 04 02:59 AM


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