using user input as search criteria

  • Thread starter Thread starter tracktraining
  • Start date Start date
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.
 
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.
 
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.
 
Back
Top