Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Multiple Workbooks

I've been attempting to use the code, from yesterday's discussion. I need to add multiple workbooks in a particular section however with no luck. This is what I have so far. Thanks

Function Split97(sStr As Variant, sdelim As String) As Variant

Split97 = Evaluate("{""" & _
Application.Substitute(sStr, sdelim, """,""") & """}")
End Function
Sub SuperGroupTestFile()
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 a As Long
Dim vArr As Variant
Dim sFname As String
Application.ScreenUpdating = False
With Application.FileSearch
.NewSearch
.LookIn = "X:\Reports2K\Reports\Daily\sg"
.SearchSubFolders = False
.FileType = msoFileTypeExcelWorkbooks
If .Execute() 0 Then
Set basebook = ThisWorkbook
rnum = 1
For i = 1 To .FoundFiles.Count
vArr = Split97(.FoundFiles(i), "\")
sFname = vArr(UBound(vArr))
If Left(sFname, 4) = "SuperGroup_02" Then
Set mybook = Workbooks.Open(.FoundFiles(i))
Set sourceRange = mybook.Worksheets(1).Range("D45:T45")
a = sourceRange.Rows.Count
Set destrange = basebook.Worksheets(1).Cells(rnum, 1)
sourceRange.Copy destrange
mybook.Close
rnum = rnum + a
End If
Next i
End If
End With
Application.ScreenUpdating = True
End Sub





  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Multiple Workbooks

Ramon,

The most obvious problem that I can see is this line

If Left(sFname, 4) = "SuperGroup_02" Then

you are comparing the leftmost 4 chyaracters of the name against a 13
character string, it will never match.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Ramon" wrote in message
...
I've been attempting to use the code, from yesterday's discussion. I need

to add multiple workbooks in a particular section however with no luck.
This is what I have so far. Thanks

Function Split97(sStr As Variant, sdelim As String) As Variant

Split97 = Evaluate("{""" & _
Application.Substitute(sStr, sdelim, """,""") &

"""}")
End Function
Sub SuperGroupTestFile()
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 a As Long
Dim vArr As Variant
Dim sFname As String
Application.ScreenUpdating = False
With Application.FileSearch
.NewSearch
.LookIn = "X:\Reports2K\Reports\Daily\sg"
.SearchSubFolders = False
.FileType = msoFileTypeExcelWorkbooks
If .Execute() 0 Then
Set basebook = ThisWorkbook
rnum = 1
For i = 1 To .FoundFiles.Count
vArr = Split97(.FoundFiles(i), "\")
sFname = vArr(UBound(vArr))
If Left(sFname, 4) = "SuperGroup_02" Then
Set mybook = Workbooks.Open(.FoundFiles(i))
Set sourceRange =

mybook.Worksheets(1).Range("D45:T45")
a = sourceRange.Rows.Count
Set destrange = basebook.Worksheets(1).Cells(rnum, 1)
sourceRange.Copy destrange
mybook.Close
rnum = rnum + a
End If
Next i
End If
End With
Application.ScreenUpdating = True
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
How do I move multiple tabs in multiple workbooks to a master? teelee Excel Worksheet Functions 3 October 15th 09 05:03 PM
Updating Workbooks from multiple links Workbooks TimJames Excel Worksheet Functions 1 December 15th 07 03:34 PM
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
adding certain cells in multiple worksheets in multiple workbooks Stephen via OfficeKB.com Excel Worksheet Functions 1 February 4th 05 08:31 PM


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