Solved

VBS SEARCH FOR SPECIFIC INFORMATION IN MULTIPLE SPREADSHEETS

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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Pull multiple cvs files into one access table 28 69
Computer crashes, following error message in event manager 5 236
MsgBox 2 59
Set WorkSheet  not Working 9 39
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…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

856 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