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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

If Find Doesn't Find Anything

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
Hello

I have got this command working now thanks, but i want to insert a message when the find doesn't find anything.

I've tried a few things but got nowhere fast

Here it is

Private Sub CommandButton1_Click()
msheet = ActiveSheet.Name
Select Case msheet
Case "BoQ"
If Application.CutCopyMode = False Then
MsgBox "Please Select Subcontractor Rates To Paste!"

Else
Range("s:s").Select
**** Selection.Find(What:=ComboBox1.Text).Activate ****

ActiveCell.Offset(0, -11).Select

Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
End If
Case Else
MsgBox "Please Select Bill Of Quantities To Enter Rates"
End Select
End Sub

Thankyou

Andrew
 
guesser,

Try this:

Code:
Set Rng = Selection.Find(What:="01", After:=ActiveCell, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:= _
        False)
        If Rng Is Nothing Then
          MsgBox "Your message here"
          Exit Sub
        End If
        Rng.Activate
...

where Rng is DIMensioned as Range

HTH,
M. Smith
Regards,
Mike
 
Thanks M Smith

I'm AMAZED, I wouldn't of got that if i tried all year!

Cheers,

Andrew
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top