+ Reply to Thread
Results 1 to 3 of 3

"Run-time error '424': Object required" error

Hybrid View

  1. #1
    Registered User
    Join Date
    05-04-2012
    Location
    Portugal
    MS-Off Ver
    Excel 2007
    Posts
    10

    "Run-time error '424': Object required" error

    Hi all,

    I'm not that experienced with Excel VBA, and after googling a little bit, I found some code that supposedly does what I need. It is here: http://stackoverflow.com/questions/3...a-certain-patt

    The code goes like this:

    Sub CopyRows()
      Dim FoundRange As Range
      Dim c As Range
    
      For Each c In Application.Intersect(Columns("L"), UsedRange)
        If c.Value like "*123*" Then
          If FoundRange Is Nothing Then
            Set FoundRange = c
          Else
            Set FoundRange = Application.Union(FoundRange, c)
          End If
        End If
      Next
    
      If Not FoundRange Is Nothing Then
        FoundRange.EntireRow.Copy Worksheets("Sheet2").Range("A4")
      End If
    
    End Sub
    When I run the code, a "Run-time error '424': Object required" error pop-up window appears, and I can't seem to fix it. Firstly, I thought I had to declare the "FoundRange" variable, but after fixing that, the error remains. I believe that it must be a basic error, but I'm not seeing the light. Can anyone help me? I would be deeply appreciated.

    I don't know if it matters at all, but I'm using Excel 2007.

    Thank you all,
    Joćo

  2. #2
    Forum Contributor
    Join Date
    06-07-2012
    Location
    London, England
    MS-Off Ver
    Excel 2010
    Posts
    189

    Re: "Run-time error '424': Object required" error

    I think it should be

    For Each c In Intersect(Columns("L"), ActiveSheet.UsedRange)

  3. #3
    Registered User
    Join Date
    05-04-2012
    Location
    Portugal
    MS-Off Ver
    Excel 2007
    Posts
    10

    Re: "Run-time error '424': Object required" error

    Exactly, Thalassa! Works like a charm now. Thank you! :] (marking it as "solved")

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1