Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / New Users / November 2006

Tip: Looking for answers? Try searching our database.

Copying only certain workbooks to a master file based on a criteria

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
thegetch1@gmail.com - 02 Nov 2006 17:32 GMT
Hi,

I have a folder with a changing number of status reports in it. Each is
standardized and only contains one tab, "Status Report".

Each status report has a cell (always B10) categorizing what type it
is.

I then have a "Infra Crit Master" that originally will have one tab
"Summary" also in the folder.

What I would like is every time the master file is opened, it will
search the folder for workbooks where B10 = True on the "Status Report"
tab. It will then make a copy of that worksheet and place this
worksheet after "Summary" in "Infra Crit Proj."

I'm not proficient at VB and cobbled together this piece of code from
other topics:

Private Sub Workbook_Open()
  Dim i As Integer, wb As Workbook
   With Application.FileSearch
   .NewSearch
   .LookIn = "\\lm-intm-01\clientdata$\n0148234\Desktop\Status Report"
   .SearchSubFolders = False
   .Filename = "*.xls"
   .Execute
   For i = 1 To .FoundFiles.Count

       Set wb = Workbooks.Open(Filename:=.FoundFiles(i))

        If (wb.Worksheets("Status Report").Range("B10") = "TRUE") Then
               wb.Worksheets("Status Report").copy
               After:=Workbooks("Infra Crit Proj").Sheets("Summary")
         End If
   Next i
   End With

End Sub

I understand most of it, but get lost at the actual copying part, not
sure of any of the conventions for refering to workbooks, worksheets,
etc. Suffice to say it doesn't work.

Any help would be greatly appreciated. Thanks!
thegetch1@gmail.com - 07 Nov 2006 14:08 GMT
Anybody want to take a stab at it?
Dave Peterson - 07 Nov 2006 15:17 GMT
What happens when you try it?

Could it be as simple as a line wrap problem?

        If (wb.Worksheets("Status Report").Range("B10") = "TRUE") Then
               wb.Worksheets("Status Report").copy _
                  After:=Workbooks("Infra Crit Proj").Sheets("Summary")
        End If

> Hi,
>
[quoted text clipped - 41 lines]
>
> Any help would be greatly appreciated. Thanks!

Signature

Dave Peterson


Rate this thread:






 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.