using user input as search criteria

T

tracktraining

Hi All,

I am wondering if there is a way to use the user input as a search criteria?

Example: a message appear for the user "what would you like to search?",
then use that word in the following code : = countif (L:L, "[user search
word]").

thanks,
tracktraining.
 
D

Dave Peterson

Maybe...

Option Explicit
Sub testme()
Dim myStr As String
Dim HowMany As Long
Dim myRng As Range

myStr = InputBox(Prompt:="For what would you like to search?")
If myStr = "" Then
Exit Sub
End If

With Worksheets("somesheetnamehere")
Set myRng = .Range("L:L")
End With

HowMany = Application.CountIf(myRng, myStr)

MsgBox "I found " & HowMany & " " & myStr & "'s"
End Sub



Hi All,

I am wondering if there is a way to use the user input as a search criteria?

Example: a message appear for the user "what would you like to search?",
then use that word in the following code : = countif (L:L, "[user search
word]").

thanks,
tracktraining.
 
T

tracktraining

thanks a lot !
--
Learning


Dave Peterson said:
Maybe...

Option Explicit
Sub testme()
Dim myStr As String
Dim HowMany As Long
Dim myRng As Range

myStr = InputBox(Prompt:="For what would you like to search?")
If myStr = "" Then
Exit Sub
End If

With Worksheets("somesheetnamehere")
Set myRng = .Range("L:L")
End With

HowMany = Application.CountIf(myRng, myStr)

MsgBox "I found " & HowMany & " " & myStr & "'s"
End Sub



Hi All,

I am wondering if there is a way to use the user input as a search criteria?

Example: a message appear for the user "what would you like to search?",
then use that word in the following code : = countif (L:L, "[user search
word]").

thanks,
tracktraining.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top