Msg box

christypraveen

New Member
Joined
Apr 11, 2020
Messages
19
Office Version
  1. 2019
  2. 2016
Platform
  1. Windows
Hi.

I need small help for msg box in Vba.

I have created so many macro button to search the item. I have used recording option to search the item. I need a VBA code for msg box when item not found...

my Vba is:

sub bottom 1_10

sheets(sheet2). select

Cells.Find (What:="search item name", After:=ActiveCell, Lookin:=xLFormulas, LookAt:=xLPart, SearchOrder:=xLByRows,Search Direction:=x1 Next, MatchCase:=False, Search Format:=False). Activate

end sub

help me VBA code for msg box when item not found using this code. Thanks in Advance
 

Excel Facts

What is =ROMAN(40) in Excel?
The Roman numeral for 40 is XL. Bill "MrExcel" Jelen's 40th book was called MrExcel XL.
Try:
VBA Code:
Sub bottom1_10()
    Sheets("Sheet2").Activate
    Dim fnd As Range
    Set fnd = Cells.Find(What:="search item name", After:=ActiveCell, LookIn:=xlFormulas, LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False, SearchFormat:=False)
    If fnd Is Nothing Then
        MsgBox "Item not found"
    Else
        fnd.Select
    End If
End Sub
 
Upvote 0
You are very welcome. :)
 
Upvote 0

Forum statistics

Threads
1,215,064
Messages
6,122,939
Members
449,094
Latest member
teemeren

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top