Run Time Error 91

counihan3

Active Member
Joined
Mar 9, 2007
Messages
458
The following code is debugging on me and I don't understand why. Can anyone see the error.

Code:
For Each myRange In Worksheets("clean").Range("A2:A" & Worksheets("clean").Range("A" & Rows.Count).End(xlUp).Row)
        Selection.AutoFilter Field:=1, Criteria1:=myRange
        a = Range("A" & Rows.Count).End(xlUp).Row
        For i = 2 To a
            If Rows(i).Hidden = False Then Exit For
        Next i
        If a <> i Then
            colmax = Application.WorksheetFunction.Max(Range(Cells(i, 21), Cells(a, 21)))
            maxadd = ActiveSheet.Range(ActiveSheet.Cells(i, 21), ActiveSheet.Cells(a, 21)).Find(colmax).Address
            MsgBox maxadd
        End If
    Next myRange
 

Excel Facts

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.
Might you tell us what line fails?

In this line the range reference is not qualified:

Code:
a = Range("A" & Rows.Count).End(xlUp).Row
 
Upvote 0
sorry, its the:

Code:
maxadd = ActiveSheet.Range(ActiveSheet.Cells(i, 21), ActiveSheet.Cells(a, 21)).Find(colmax).Address
 
Upvote 0
That means the value wasn't found and you can't return the Address of Nothing.
 
Upvote 0
you probably need to specify the rest of the find arguments like Lookin, Lookat.
 
Upvote 0
And you have a mix of qualified and unqualified range references that should all be qualified.
 
Upvote 0

Forum statistics

Threads
1,224,581
Messages
6,179,668
Members
452,936
Latest member
anamikabhargaw

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