![]() |
using user input as search criteria
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. -- Learning |
using user input as search criteria
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 tracktraining wrote: 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. -- Learning -- Dave Peterson |
using user input as search criteria
thanks a lot !
-- Learning "Dave Peterson" wrote: 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 tracktraining wrote: 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. -- Learning -- Dave Peterson |
All times are GMT +1. The time now is 12:08 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com