Cells.Find method with multiple "What" values

KC Cat

New Member
Joined
Dec 23, 2009
Messages
48
Hello to all,

I have a worksheet with IF statements that place different messages in cells if the user has not provided enough information, or incorrect information, etc. Here are the messages:

Check % Complete
Actual Missing
Remaining Missing
Zero Out Remaining
??
enter date
Qty?

I am trying to create a macro that will check the entire worksheet (that can be quite large) for instances of the values above. I want it to be very simple. The user will click a button, and the code will try to find the first instance of any of these "What" values and stop running for the user to address the issue. Then, they would simply click it again and again, until there are no more found, at which point, there will be a message stating "No incomplete inputs were found."

My problem is with the error handling aspects of this idea. If I only have one "What" value to find, I can do what I need to do without any help. It's the multiple "What" values aspect that is causing problems.

With the code below, it works when tested only under certain circumstances, but not all. I need to figure out a way for it to look for the first, and if it doesn't find any, go to the second, etc. If it finds one, the code should stop running with that instance activated for the user to address. If it finds none, it should tell the user that "No incomplete inputs were found."

Thanks in advance for considering my inquiry. For simplicity sake, the code below only includes the first to "What" values from above.

Sub Search_for_Incomplete_Inputs()

MsgBox "This search will attempt to find instances of the following: Check % Complete, Actual Missing, Remaining Missing, Zero Out Remaining, ??, enter date, Qty?" & vbNewLine & vbNewLine & "NOTE: You may have to execute this search multiple times until none are found.", vbInformation, "Incomplete Input Search"

On Error GoTo ErrorHandler:

Range("A4").Select

Cells.Find(What:="Check % Complete", After:=ActiveCell, LookIn:=xlValues _
, LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False).Activate

Range("A4").Select

Cells.Find(What:="Actual Missing", After:=ActiveCell, LookIn:=xlValues _
, LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False).Activate

If Err.Number = 1 Then
MsgBox "No incomplete inputs were found.", vbInformation, "Incomplete Input Search"
Else
Exit Sub
End If


ErrorHandler:
If Err.Number <> 0 Then
Err.Number = 1
End If

End Sub
 

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.

Forum statistics

Threads
1,223,228
Messages
6,170,871
Members
452,363
Latest member
merico17

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