Run time error 424

rinijg

New Member
Joined
May 13, 2011
Messages
47
Hi, I was trying to run the a code for which" run time error 424, object required" error occured. While debugging i found that the error is in Set rsearch line...
Dim rSearch As Range 'range to search
Worksheets("database").Activate
Set rSearch = database.Range("a6", Range("a65536").End(xlUp))

Could you please tell me what to do to clear that error?:mad::confused::(
Thanks a lot <!-- google_ad_section_end --><!-- / message -->
 
wow...
where did you put the code? did u create a command button in estimation sheet and put the code in the command button?
 
Upvote 0

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK
Found the issue:

Code:
Set rSearch = database.Range("a6", Range("a65536").End(xlUp))

Should be:

Code:
Set rSearch = database.Range("a6", database.Range("a65536").End(xlUp))
 
Upvote 0
Hi, problem again....:mad:
now its showing run time error 9, subscript out of range for the following line
Set database = ActiveWorkbook.Worksheets("database")
what to do??? :mad::mad:
 
Upvote 0
Code:
Dim c          As Range
Dim rng As Range
Private Sub CommandButton1_Click()
                
Dim strFind As String    'what to find
    Dim FirstAddress As String
Dim rSearch As Range 'range to search
Dim database As Worksheet
'Worksheets("find_result").Range("A3:AP65536").ClearContents
Set database = ActiveWorkbook.Worksheets("database")
database.Activate
Set rSearch = database.Range("a3", database.Range("a65536").End(xlUp))
    Dim f      As Integer
    strFind = Worksheets("Estimation").Range("B2").Value    'what to look for
 
    With rSearch
        Set c = .Find(strFind, LookIn:=xlValues)
        If Not c Is Nothing Then    'found it
            c.Select
      
            For i = 0 To 31
            
              Worksheets("Find_Result").Cells(3, i + 1).Value = c.Offset(0, i).Value
           Next i
           
   f = 0
            FirstAddress = c.Address
            Do
                f = f + 1    'count number of matching records
                Set c = .FindNext(c)
            Loop While Not c Is Nothing And c.Address <> FirstAddress
            If f > 1 Then
                Select Case MsgBox("There are " & f & " instances of " & strFind, vbOKCancel Or vbExclamation Or vbDefaultButton1, "Multiple entries")
                    Case vbOK
                        FindAll
                    Case vbCancel
                        'do nothing
                End Select
                
            End If
        Else: MsgBox strFind & " not listed"    'search failed
        End If
    End With
    Worksheets("database").Activate
End Sub
Sub FindAll()
    Dim strFind As String    'what to find
    Dim rFilter As Range     'range to search
    Dim database As Worksheet
   
    Set database = ActiveWorkbook.Worksheets("database")
  database.Activate
Set rFilter = database.Range("a3", database.Range("ap65536").End(xlUp))
    strFind = Worksheets("Estimation").Range("B2").Value
    With Worksheets("database")
        If Not .AutoFilterMode Then .Range("A3").AutoFilter
        rFilter.AutoFilter Field:=1, Criteria1:=strFind
        Set rng = rng.Cells.SpecialCells(xlCellTypeVisible)
  
        j = 3
        For Each c In rng
        
            For i = 0 To 31
            
              Worksheets("Find_Result").Cells(3, i + 1).Value = c.Offset(0, i).Value
           Next i
           j = j + 1
        
        Next c
    End With
    Worksheets("find_result").Activate
End Sub

this is my code.... please help me:mad:
 
Upvote 0
Does this happen when you call the command button on click event or the findall macro
 
Upvote 0

Forum statistics

Threads
1,224,599
Messages
6,179,831
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