Solved

VBS SEARCH FOR SPECIFIC INFORMATION IN MULTIPLE SPREADSHEETS

Posted on 2004-09-15
5
278 Views
Last Modified: 2010-05-02
I have multiple Excel spreadsheets on a server at
 S:\SVCDrive\ADQSR EP Project Docs\Site Surveys\Logged\Site Surveys

The names of the surveys are a  6 digit site  number and survey ######survey.xls

What I need to do is search in each of these surveys for the following fields

A84                                    B84
Register eprom level (from database)                  VARIABLE VALUE
A85                                    B85
Confirmed emprom level (from master terminal)            VARIABLE VALUE

On every sheet I need to grab A84 AND B84 , A85 AND B85

Once the search is complete I would like to have a report that looks like this

6 digit number= a84 b84
                        a 85 b85

6 digit number= a84 b84
                        a 85 b85

6 digit number= a84 b84
                        a 85 b85

There are several hundred surveys to open and grab info from.

Thanks



                           
0
Comment
Question by:irishmanjb
  • 3
  • 2
5 Comments
 
LVL 9

Expert Comment

by:samopal
ID: 12068308
  Dim fso as object, fold as object, fil as object, exl as object
   Set exl = CreateObject("Excel.Application")
   Set fso = CreateObject("Scripting.FileSystemObject")
   Set fold = fso.GetFolder("S:\SVCDrive\ADQSR EP Project Docs\Site Surveys\Logged\Site Surveys")
   For Each fil in fold.Files
      if Right(fil.name,10) = "survey.xls" then
          exl.Workbooks.open "S:\SVCDrive\ADQSR EP Project Docs\Site Surveys\Logged\Site Surveys\" & fil.name
debug.print Left(fil.name,6)
debug.print exl.ActiveSheet.Range("A84"),exl.ActiveSheet.Range("B84")
debug.print exl.ActiveSheet.Range("A85"),exl.ActiveSheet.Range("B85")
          exl.ActiveWorkbook.Close
      end if
   Next
   exl.quit
   set exl=nothing
   set fso=nothing

D'Al
0
 

Author Comment

by:irishmanjb
ID: 12069420
This function seems to be opening and changing all of the surveys somehow because I am being prompted to save the changes in all surveys.

Also if it makes this any easier.  I can get by with the 6 digit number in one column and the value from b85 in the other for all of the spreadsheets.

thanks          
0
 
LVL 9

Expert Comment

by:samopal
ID: 12069480
<<I am being prompted to save the changes in all surveys
Change line
 exl.ActiveWorkbook.Close
to
 exl.ActiveWorkbook.Close False
0
 

Author Comment

by:irishmanjb
ID: 12073982
Thanks
I made the change and ran it but nothing seems to happen.
Ther macro runs but I am not getting any results in the active workbook.
0
 
LVL 9

Accepted Solution

by:
samopal earned 500 total points
ID: 12076590
Are you running this as a script? then you have to change all debug.print command s to your output commands.
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

26 Experts available now in Live!

Get 1:1 Help Now