ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   VBA search code (https://www.excelbanter.com/excel-programming/355848-vba-search-code.html)

Gustavo Strabeli

VBA search code
 
Hi there!
Would like to have a UDF / VBA code for a pragmatic search engine

Plan1 - The search criterions
Plan2 - My database. Here I have, among some columns, one named "Location"
and another one named "Port Code".
Plan3 - Blank. Here I'd like to have the search results.

In some extents, what I need is:

To have on Plan1 two text boxes (on B1 and B2, for instance) where I can
type what I want to look for.
Either I want to know what is the location code for the port of New York,
then I type "New York" on B1
Or I have a port code and want to know what "USNYC" stands for, I type it on
B2

So, when I have typed the condition I want (either Location or Port Code), I
click OK button, Excel looks for the data on my database on Plan2 and brings
all the results on Plan3.
I'd like also to have all the results in case I type only a part of a name,
i.e., if I type "Charl", I need to have as result: Charles, Charleston,
Charlotte, Saint Charles, Cape Charles...

Is it possible?
Please advise if you need further clarification.

Thanks a bunch,
Gustavo




Ed

VBA search code
 
Gustavo:

I have a search macro that runs through every row looking for a text string.
In my macro, the row is hidden if it doesn't find the string. It finds
partial strings as well. I use:
Set myFind = Rows(i).Find(What:=myTarget, LookAt:=xlPart)
If myFind Is Nothing Then
Selection.EntireRow.Hidden = True
End If
where myFind is a Range object and myTarget is the contents of a cell.

If you change the return to
If Not myFind Is Nothing Then
then you'll be able to do something with the result.

HTH
Ed

"Gustavo Strabeli" wrote in message
...
Hi there!
Would like to have a UDF / VBA code for a pragmatic search engine

Plan1 - The search criterions
Plan2 - My database. Here I have, among some columns, one named "Location"
and another one named "Port Code".
Plan3 - Blank. Here I'd like to have the search results.

In some extents, what I need is:

To have on Plan1 two text boxes (on B1 and B2, for instance) where I can
type what I want to look for.
Either I want to know what is the location code for the port of New York,
then I type "New York" on B1
Or I have a port code and want to know what "USNYC" stands for, I type it
on
B2

So, when I have typed the condition I want (either Location or Port Code),
I
click OK button, Excel looks for the data on my database on Plan2 and
brings
all the results on Plan3.
I'd like also to have all the results in case I type only a part of a
name,
i.e., if I type "Charl", I need to have as result: Charles, Charleston,
Charlotte, Saint Charles, Cape Charles...

Is it possible?
Please advise if you need further clarification.

Thanks a bunch,
Gustavo







All times are GMT +1. The time now is 12:03 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com