Command button code like userform.show

ipbr21054

Well-known Member
Joined
Nov 16, 2010
Messages
5,226
Office Version
  1. 2007
Platform
  1. Windows
Evening.
I am using the code below.
After i have been told that the item exists or does not exist i click on OK and the message box closes.
I then need to click again on the command button3 to show me the box & type in another number.

What i would like is to be able to apply something like userform.show code so it opens again without me doing it each time.
The also have the option to close it manually myself once finished.


Code:
Private Sub CommandButton3_Click()'Modified  10/14/2018  8:12:52 AM  EDT
Application.ScreenUpdating = False
Dim ans As String
Dim rr As Long
Dim LastRow As Long
LastRow = Cells(Rows.Count, "A").End(xlUp).Row
ans = InputBox("Enter search for value")
Set SearchRange = Range("A3:A" & LastRow).Find(ans)
If SearchRange Is Nothing Then MsgBox "The Part Number " & ans & " Is Not In The List", vbCritical: Exit Sub
rr = SearchRange.Row
MsgBox "The Part Number  " & ans & "  Can Be Found In Row  " & rr, vbExclamation
Application.ScreenUpdating = False
End Sub
 
The second msgbox should be
Code:
If MsgBox("The Part Number  " & ans & "  Can Be Found In Row  " & Fnd.Row[COLOR=#ff0000] & [/COLOR]vbLf & vbLf & "Search For Another", vbYesNo) = vbYes Then Set Fnd = Nothing Else Exit Sub
 
Upvote 0

Excel Facts

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.
Thanks very much,i didnt think it was anything major but i didnt spot it.

Now all ok,have a good weekend.
 
Upvote 0

Forum statistics

Threads
1,215,376
Messages
6,124,593
Members
449,174
Latest member
chandan4057

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