Excel VBA - Search Two Different Cells For A Match
I am working on a VBA app that picks certain pieces of information from a whole bunch of other spreadsheets and creates what is essentially a summary page. In addition to what it gathers, there are columns on the spreadsheets for other things (like dates) that is manually entered by the user.
Each of the spreadsheets that it gathers information from can have numerous versions housed in separate spreadsheet files. An example of the naming convention is:
hack06302009O.xls - the O = Originial
hack063020091R.xls - the 1R = first revision
hack063020092R.xls = the 2R = second revision
so on and so forth
The filename itself gets parsed with the first part being hack06302009 and the second part being the revision number, i.e., O, 1R, 2R, etc
Both are saved in separate columns on the summary sheet.
What I need to do prior to making a new entry is search the existing summary sheet to see if the file being loaded already exists on the sheet. In other words, if the user selects hack063020091R.xls to load, I need to search column B to see if hack06302009 exists and column F to see if 1R exists. If both are true, then I simply display the summary sheet and make no new entry. If either is False, I make a new entry.
This all works at the moment, but in order to get it to work I'm doing two separate searchs. I set the range to B:B then do a Cells.Find(what:='hack06302009') then set the range to F:F and do a Cells.Find(what:='1R')
Here is my question: Is there a better, more efficient, way of doing a search on two different cells?
I don't answer coding questions via PM or Email. Please post a thread in the appropriate forum section.
Please use [Code]your code goes in here[/Code] tags when posting code.
Before posting your question, did you look here
Got a question on Linux? Visit our Linux sister site.
Modifications Required For VB6 Apps To Work On Vista
By slimasian in forum .NET
Last Post: 05-15-2008, 04:24 PM
By batman61 in forum VB Classic
Last Post: 02-11-2008, 01:51 PM
Last Post: 01-02-2007, 08:58 AM
By Werner in forum VB Classic
Last Post: 06-15-2005, 02:13 PM
By Bob in forum VB Classic
Last Post: 03-14-2002, 02:27 PM
Tags for this Thread
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL