Simple input msgbox ask for number and if it finds it, says already exists

Status
Not open for further replies.

Caveman1964

Board Regular
Joined
Dec 14, 2017
Messages
127
Office Version
  1. 2016
Platform
  1. Windows
I would like a macro that activates an input box asking for a job number. Macro is on sheet 2.
They enter job number and it searches sheet 3 from A7:A2500
If it finds it, a message says "Job already exists, would you like to try another?" yes or no, if no exit.
if yes then option to enter another.
I have so tried it and my crap doesn't come close to working.
Can one of you guys/gals help me?
Thanks
 

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.
This has a never-ending loop! It worked fine with Sheet name "Sheet3" and within the range "A7:A2500" of the sheet.



Sub find_j_num()
Dim job_num As String, cont_sch As Integer, never_ending_loop As Boolean
never_ending_loop = True
While never_ending_loop
With Worksheets("Sheet3").Range("A7:A2500")
job_num = InputBox("Enter the job number.")
If Not .Find(job_num) Is Nothing Then
cont_sch = MsgBox("Job already exists. Would you like to try another?", vbYesNo)
If cont_sch = vbNo Then Exit Sub
Else
cont_sch = MsgBox("Job does not exist. Would you like to try another?", vbYesNo)
If cont_sch = vbNo Then Exit Sub
End If
End With
Wend
End Sub
 
Upvote 0
KolGuyXcel!!!
Worked perfect and smooth. Thanks for spending your personal time writing this!
 
Upvote 0
The only thing it doesn't do is when It doesn't find the number, it doesn't enter.
how would I write that if the number isn't there, it places it in cell E5 of Sheet 2?
 
Upvote 0
Status
Not open for further replies.

Forum statistics

Threads
1,223,901
Messages
6,175,277
Members
452,629
Latest member
SahilPolekar

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