+ Reply to Thread
Results 1 to 5 of 5

Finding the correct value

  1. #1
    Forum Contributor CobraLAD's Avatar
    Join Date
    07-23-2007
    Location
    Boksburg, South Africa
    MS-Off Ver
    Office 2019
    Posts
    346

    Finding the correct value

    I have all my items on sheet1 with a history to the right of each item. I am using advanced filter, to filter the item on sheet5. I want to see where my short items was before the are marked short, that means the second last entry on the history. This code gives an error "Object variable or With block variable not set"

    Please Login or Register  to view this content.
    I want to find the second last entry of the history on sheet1 and display it on sheet5, 7 columns away from each item
    Last edited by CobraLAD; 01-09-2013 at 07:44 AM.

  2. #2
    Forum Expert
    Join Date
    07-16-2010
    Location
    Northumberland, UK
    MS-Off Ver
    Excel 2007 (home), Excel 2010 (work)
    Posts
    3,054

    Re: Finding the correct value

    You're running both a .End and a .Offset on the results of a .Find - so if the value you're looking for isn't found then the .Find will return a range of Nothing, which will generate a 1004 error when you try to .End or .Offset from it.

    You should use a Set to assign the result of the .Find to a range type variable and then check that variable is not Nothing before attempting to do anything with the range returned.

  3. #3
    Forum Contributor CobraLAD's Avatar
    Join Date
    07-23-2007
    Location
    Boksburg, South Africa
    MS-Off Ver
    Office 2019
    Posts
    346

    Re: Finding the correct value

    Thanks Andrew, understand what you are saying, but not sure how to set it up.

    I got it to work.
    Please Login or Register  to view this content.

  4. #4
    Forum Contributor CobraLAD's Avatar
    Join Date
    07-23-2007
    Location
    Boksburg, South Africa
    MS-Off Ver
    Office 2019
    Posts
    346

    Re: Finding the correct value

    Thanks Andrew, understand what you are saying, but not sure how to set it up.

    I got it to work.
    Please Login or Register  to view this content.

  5. #5
    Forum Expert OllieB's Avatar
    Join Date
    12-20-2012
    Location
    Netherlands
    MS-Off Ver
    Excel 2007 (home) & 2010 (office)
    Posts
    1,542

    Re: Finding the correct value

    CobraLAD,

    You almost had it

    change
    Please Login or Register  to view this content.
    into
    Please Login or Register  to view this content.
    If you like my contribution click the star icon!

+ 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