Looking for duplicates/FindAll

meridius10

New Member
Joined
Apr 30, 2011
Messages
47
I am looking to make amendments to the following code so that it will find multiple duplicate numbers, similar to FindAll, and then move from one number to the next.

So for example if the number '201' appears twice this is reported, or preferably moves in sequence down twice.

Code:
Sub findobjectnumber()
    On Error GoTo z
    Dim x As Integer
    Dim y As Range
    Set y = Range("A:A")
    Set w = Range("A2")
    w.Select
    x = InputBox("Enter the object number below")
    y.Find(What:=x, _
    After:=ActiveCell, LookIn:=xlFormulas, LookAt:=xlWhole, _
    SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:= _
    False).Activate
    Exit Sub
z:
    MsgBox ("Object number does not exist. Try again.")
End Sub
 

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.
OK - I have found a solution with help from our friend the macro recorder:

Code:
Sub findonumbtest()
Dim x As Integer
Selection.AutoFilter Field:=1
x = InputBox("Enter the object number below")
    Selection.AutoFilter Field:=1, Criteria1:=x, Operator:=xlAnd
End Sub
However I am getting Runtime error 1004, "You cannot use this command on an unprotected sheet".

My other code, which I initially wrote in Module1, still runs fine without this error message and with protection switched on. I must keep protection on this sheet. Is there a workaround?
 
Upvote 0

Forum statistics

Threads
1,224,600
Messages
6,179,836
Members
452,947
Latest member
Gerry_F

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