VBA Search engine dropdownlist

darkdarkwt

New Member
Joined
Jun 9, 2015
Messages
3
hello , i need to write a search engine vba code for ms excel . i manage to create the search engine form, but i'm stuck at where to continue and write for the search coding.
however, i am wondering would it be easier if i use ms access , but my question is how to let ms access to search thru all worksheet?

the idea is to allow user to select criteria from the drop down list. When button search is clicked , macro will run and search thru all the worksheet, not all selections are needed.

it will be better if you can help me with example

i'm so sorry as i'm quite new in excel , thank you so much for anyone who help me ><
 

Excel Facts

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.

L. Howard

Well-known Member
Joined
Oct 16, 2012
Messages
4,514
Hi darkdarkwt,

Maybe start with something like this and adapt.

Here is the code that is in the workbook in the link.

https://www.dropbox.com/s/svbhcxqo9j6jcvi/Find name or value on all sheets Drop Box.xlsm?dl=0

Click the button on Sheet1 and follow the prompt.

Then look at sheet Cumulative Data for the results in column B, cell address, sheet name, the search value.

Howard

Code:
Option Explicit

Sub AllMySheets()
'/ me code
Dim ws As Worksheet
Dim FindString As String
Dim Rng As Range
Dim bFoundID As Boolean

FindString = InputBox("Enter a search item from column F")

For Each ws In ThisWorkbook.Worksheets
  If ws.Name <> "Sheet1" Then
    
    If Trim(FindString) <> "" Then
    
        With ws
            Set Rng = .UsedRange.Find(What:=FindString, _
                       LookIn:=xlValues, _
                       LookAt:=xlWhole, _
                       SearchOrder:=xlByColumns, _
                       SearchDirection:=xlNext, MatchCase:=False, _
                       SearchFormat:=False)

            If Not Rng Is Nothing Then
               Sheets("Cumulative Data").Range("B" & Rows.Count).End(xlUp)(2) = _
               Rng.Address & " " & ws.Name & " - " & FindString                          
            End If
            
        End With
        
    End If
    
  End If
 
Next ws

End Sub
 
Upvote 0

Forum statistics

Threads
1,195,650
Messages
6,010,915
Members
441,572
Latest member
keobongda8812

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top