Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Merging multiple excel files into 1, almost there just need some help

Thanks in advance for any help you can offer me, it is greatly
appreciated.

I took some sample code from here an earlier discussion he
http://groups.google.com/group/micro...72d199e2601a33

However I want to import from an excel file that looks like:
A1 A2
company Company inc
address 12312 grey blvd

And change it into:
A1 A2
Company inc 12312 grey blvd

Basically get all of the company information from various excel files
and then insert them as one row each into a master file that holds
all of the companies. I know some VBA but I am not that great at it.
Please tell me where I need to change in my code. I believe it is
this line:

Set destrange = basebook.Worksheets(2).Cells(1, rnum). _
Resize(.Rows.Count, .Columns.Count)


Sub File_crawl_consolodate_values()
Dim basebook As Workbook
Dim mybook As Workbook
Dim sourceRange As Range
Dim destrange As Range
Dim rnum As Long
Dim i As Long
Dim j As Long
Dim a As Long
Application.ScreenUpdating = False
With Application.FileSearch
..NewSearch
..LookIn = "C:\Data\excels"
..SearchSubFolders = True
..FileType = msoFileTypeExcelWorkbooks
If .Execute() 0 Then
Set basebook = ThisWorkbook
rnum = 1
For i = 1 To 2 '.FoundFiles.Count
For j = 1 To 1
Select Case j

Case 1
Set mybook = Workbooks.Open(.FoundFiles(i))
Set sourceRange = mybook.Worksheets(2).Range("B1:B7")
a = sourceRange.Rows.Count
With sourceRange
Set destrange = basebook.Worksheets(2).Cells(1, rnum). _
Resize(.Rows.Count, .Columns.Count)
End With
destrange.Value = sourceRange.Value

mybook.Close
rnum = rnum + a
End Select
Next j
Next i
End If
End With
End Sub

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
merging excel files A.A.A Excel Discussion (Misc queries) 3 September 3rd 08 02:23 PM
merging multiple files/sheets into one [email protected] Excel Programming 2 August 29th 06 08:07 PM
Merging Excel Files Lupe Excel Programming 3 August 1st 06 02:26 PM
merging multiple files ILXCEL Excel Discussion (Misc queries) 1 March 27th 06 06:16 PM
merging my excel files Donna YaWanna Excel Discussion (Misc queries) 1 June 14th 05 12:53 AM


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