+ Reply to Thread
Results 1 to 2 of 2

Why doesn't ths VBA Code work?

  1. #1
    Mac Lingo
    Guest

    Why doesn't ths VBA Code work?

    Help!

    I can run this code from inside a simple Macro called subroutine with ARG
    replaced by a string. But when I put it in another function and call it
    from within my own code, I get a 424 Error, "Object required" error. And it
    was running until an hour ago. Anyidea what's going on?

    Many thanks,
    Mac Lingo
    Berkeley, CA

    =============================================================
    The Code

    Range("A1").Select

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



  2. #2
    Barry
    Guest

    RE: Why doesn't ths VBA Code work?

    I think the find isn't locating the ARG value on the activesheet. this means
    then that No Object (a range) has been set and so it can't activate it.

    try replacing you one liner with these extra lines:

    Set rng = Cells.Find(What:=ARG, After:=ActiveCell, LookIn:=xlValues, _
    LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
    MatchCase:=False)

    If rng Is Nothing Then
    MsgBox ARG & " not found on active sheet."
    Else
    rng.Activate
    End If

    HTH

    Barry


    "Mac Lingo" wrote:

    > Help!
    >
    > I can run this code from inside a simple Macro called subroutine with ARG
    > replaced by a string. But when I put it in another function and call it
    > from within my own code, I get a 424 Error, "Object required" error. And it
    > was running until an hour ago. Anyidea what's going on?
    >
    > Many thanks,
    > Mac Lingo
    > Berkeley, CA
    >
    > =============================================================
    > The Code
    >
    > Range("A1").Select
    >
    > Set rng = Cells.Find(What:=ARG, After:=ActiveCell, LookIn:=xlValues, _
    > LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
    > MatchCase:=False, SearchFormat:=False).Activate
    >
    >
    >


+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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