+ Reply to Thread
Results 1 to 6 of 6

Date parameter search function

Hybrid View

  1. #1
    Registered User
    Join Date
    09-05-2011
    Location
    Ryther, England
    MS-Off Ver
    Office 365
    Posts
    63

    Date parameter search function

    Hi guys

    Is it possible to create a date parameter search function.

    As an example I have a list of stock items with quantities that have been bought on certain days. Is it possible to create functionality to be able to type in 2 dates, a stock item and get a return of number of the stock item bought within that date period.

    Any help greatly appreciated.

    Regards.

  2. #2
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Date parameter search function

    Hi macquhele:

    This is set up for dates in Column A And Output on sheet 1 in the same book:

    Sub SoldbyDate(BDate As Date, EDate As Date)
    Dim SDate As Date, D As Range, r As Long
    r = Worksheets("Sheet1").Range("A" & Rows.Count).End(xlUp).row
    For Each D In Range("A2:A" & Range("A" & Rows.Count).End(xlUp).row)
    SDate = D
    If SDate >= BDate And SDate <= EDate Then
    
    D.EntireRow.Copy Worksheets("Sheet1").Range("A" & r): r = r + 1
    End If: Next:End Sub
    And you invoke it like this:

    Call SoldbyDate(#6/15/2012#, #10/15/2012#)
    If I've helped you, please consider adding to my reputation - just click on the liitle star at the left.

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~(Pride has no aftertaste.)

    You can't do one thing. XLAdept

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~aka Orrin

  3. #3
    Registered User
    Join Date
    09-05-2011
    Location
    Ryther, England
    MS-Off Ver
    Office 365
    Posts
    63

    Re: Date parameter search function

    Hi there.

    Thank you for the quick response. I struggled to get your code to work to be honest. I've attached a sample database of what I am trying to achieve. Will the above code assist with this?

    Thnaks again for your help.

    Regards
    Attached Files Attached Files

  4. #4
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Date parameter search function

    Hi macquhele,

    I couldn't get it to work by clicking the Rectangle - although i think I've done it before. This version will run after you change the entry in H13! See if it will do for you:Biscuits().xlsm

  5. #5
    Registered User
    Join Date
    09-05-2011
    Location
    Ryther, England
    MS-Off Ver
    Office 365
    Posts
    63

    Re: Date parameter search function

    Hi there

    This is great thank you. Very clever.

    Regards

  6. #6
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Date parameter search function

    You're welcome!

+ 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