Solved

VBS SEARCH FOR SPECIFIC INFORMATION IN MULTIPLE SPREADSHEETS

Posted on 2004-09-15
5
280 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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

809 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