Solved

VBS SEARCH FOR SPECIFIC INFORMATION IN MULTIPLE SPREADSHEETS

Posted on 2004-09-15
5
284 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

739 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