Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

MsgBox Help 1

Status
Not open for further replies.

wiginprov

Technical User
May 5, 2001
35
US
I have a macro that searches a database for a tax id number. I need a message box that reads "Tax id number not found" if the tax id number is not in the database. How do I do that? Here is my syntax:


Dim strMessage As String
strMessage = Application.InputBox("ENTER TAX I.D. NUMBER (Example: ###-##-####)", "SEARCH FOR TAX ID#")
Let ActiveSheet.Cells(4, 22) = strMessage

Range("A7:A10030").AdvancedFilter Action:=xlFilterInPlace, CriteriaRange:= _
Range("V3:V4"), Unique:=False


Many thanks.


 
Hi wiginprov,

The following seems to work. As you'll notice I tested on a small range:

Sub test()
Dim strMessage As String
Dim rngDataRange As Range

strMessage = Application.InputBox("Enter Integer)", "Search for Integer")

Set rngDataRange = Application.ActiveSheet.Range("A5:A9")

With rngDataRange
Set c = .Find(What:=strMessage)
If Not c Is Nothing Then
ActiveSheet.Range("A2") = strMessage
rngDataRange.AdvancedFilter Action:=xlFilterInPlace, CriteriaRange:= _
Range("A1:A2"), Unique:=False
Else
MsgBox "Sorry, " & strMessage & " not found"
End If
End With

End Sub


Hope you like it.

IS
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top