LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 151
Default HELP TO COMBINE MULTIPLE SHEETS IN MULTIPLE WORKBOOKS

Hi,
I tried with Mike's code (multiple file question) given below, it works for
a fixed range and for the 1st sheet of workbook.
But I want to combine advance(sheet1),deposits(sheet2), creditors(sheet3),
so on...Sheet names are unique. Validation must be done at h column starting
row 6 for value & grab the row until value = "LLINE" or BLANK, similarly it
should check value in g column for deposit sheet, i column in prepaid sheet,
& so on... The consol file should have data for each sheet from all files (in
their respective sheets advance, deposit,..).
Hope I explained... Can any one modify his code to check sheet names, cell
values & help me.. thanks in advance.
I am using excel 2002.

Mike's code:
Sub DAC_Report()
Dim basebook As Workbook
Dim mybook As Workbook
Dim sourceRange As Range
Dim destrange As Range
Dim SourceRcount As Long
Dim N As Long
Dim rnum As Long
Dim MyPath As String
Dim SaveDriveDir As String
Dim FName As Variant

SaveDriveDir = CurDir
'MyPath = "C:\Data"
'ChDrive MyPath
'ChDir MyPath
FName = Application.GetOpenFilename(filefilter:="Excel Files (*.xls),
*.xls", _
MultiSelect:=True)
If IsArray(FName) Then
Application.ScreenUpdating = False
Set basebook = ThisWorkbook
rnum = 1
basebook.Worksheets(1).Cells.Clear
'clear all cells on the first sheet

For N = LBound(FName) To UBound(FName)
Set mybook = Workbooks.Open(FName(N))
Set sourceRange = mybook.Worksheets(1).Range("A3:F53")
SourceRcount = sourceRange.Rows.Count
Set destrange = basebook.Worksheets(1).Cells(rnum, "A")

basebook.Worksheets(1).Cells(rnum, "G").Value = mybook.Name
' This will add the workbook name in column D if you want

sourceRange.Copy destrange
' Instead of this line you can use the code below to copy only
the values

' With sourceRange
' Set destrange = basebook.Worksheets(1).Cells(rnum,
"A"). _
' Resize(.Rows.Count, .Columns.Count)
' End With
' destrange.Value = sourceRange.Value

mybook.Close False
rnum = rnum + SourceRcount
Next
End If
Columns("G:G").Font.Size = 8
Columns("G:G").Font.Bold = True
' ChDrive SaveDriveDir
' ChDir SaveDriveDir
Application.ScreenUpdating = True
End Sub


Eddy Stan

 
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
Combine multiple workbooks into one workbook YM TEO Excel Discussion (Misc queries) 4 March 31st 09 08:17 AM
Combine multiple workbooks into 1 workbook w/ multiple worksheets buffgirl71 Excel Discussion (Misc queries) 1 May 13th 06 12:28 PM
Combine multiple workbooks into 1 workbook w/ multiple worksheets buffgirl71 Excel Discussion (Misc queries) 2 May 12th 06 10:30 PM
Combine multiple workbooks into one workbook Rookie_User Excel Discussion (Misc queries) 0 January 13th 06 06:56 PM
Combine tabs from multiple workbooks into one Alayna Excel Discussion (Misc queries) 1 September 1st 05 07:55 PM


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