+ Reply to Thread
Results 1 to 2 of 2

Column Search Function

  1. #1
    Insomniac53
    Guest

    Column Search Function

    I am trying to write a function that will search a column for a particular date and return the row number. The dates are in order although there may be duplicates. If it can't find that date, then it must keep searching for a day earlier each time until it finds any date after January 1st or an error code if the column is empty. If it finds duplicate dates, the function must return the row of the last/latest one.

    Example, suppose the column has ten dates, 2 at January 1st, 2 at February 1st and 6 at March 1st. I ask the function to return the row number of February 28th. It should return the number 4 because there are only 4 rows up to that date.

    I'm afraid I can't get my head around this at all. I think it will need VLOOKUP in a backwards searching loop, but I'm not sure how to code it. Any suggestions? Thanks!

    I may not be around to answer questions about this immediately, but I will respond as soon as I can.

  2. #2
    Forum Expert Domski's Avatar
    Join Date
    12-14-2009
    Location
    A galaxy far, far away
    MS-Off Ver
    Darth Office 2010
    Posts
    3,950

    Re: Column Search Function

    Have a look at the the Match function, you can then combine that with Index.

    Dom
    "May the fleas of a thousand camels infest the crotch of the person who screws up your day and may their arms be too short to scratch..."

    Use code tags when posting your VBA code: [code] Your code here [/code]

    Remember, saying thanks only takes a second or two. Click the little star to give some Rep if you think an answer deserves it.

+ 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