+ Reply to Thread
Results 1 to 5 of 5

Excel 2007 : Macro return First and Last dates in visible cells

  1. #1
    Registered User
    Join Date
    08-13-2010
    Location
    Brisbane, Australia
    MS-Off Ver
    Excel 2003
    Posts
    18

    Smile Macro return First and Last dates in visible cells

    Hi,

    Is there any macro that can return the first and the last dates from visible cells within a date formated column in a data sheet to the nominated cells in the report sheet?

    For example after filtering say by a customer name the dates of transactions are as follows (in the data sheet):

    1/08/2010
    6/08/2010
    17/08/2010

    In the Report worksheet Say Column A Row 5 is "From: and Column B Row 5 is blank to insert the first date of the customers from the visible cell (Eg. 1/08/2010) and Column C Row 5 is "To" with Column D Row 5 is blank to receive the last visible date (Eg. 17/08/2010)

    Appreciate any help. I use Excel 2007

    Thank you,

    Yogi

  2. #2
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Macro return First and Last dates in visible cells

    Use the SUBTOTAL() function on the whole range of dates. Two of the functions inside SUBTOTAL are MIN and MAX. Those should get you what you want.

    =SUBTOTAL(104, $F$2:$F$100) - MAX
    =SUBTOTAL(105, $F$2:$F$100) - MIN
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  3. #3
    Forum Expert MickG's Avatar
    Join Date
    11-23-2007
    Location
    Banbury,Oxfordshire
    Posts
    2,650

    Re: Macro return First and Last dates in visible cells

    Hi, Try this:-
    Dates assumed to be in Column "A".

    Please Login or Register  to view this content.
    Regards Mick

  4. #4
    Registered User
    Join Date
    08-13-2010
    Location
    Brisbane, Australia
    MS-Off Ver
    Excel 2003
    Posts
    18

    Re: Macro return First and Last dates in visible cells

    Thank you Jerry for your prompt response. Much appreciated.

    Regards,

    Yogi

  5. #5
    Registered User
    Join Date
    08-13-2010
    Location
    Brisbane, Australia
    MS-Off Ver
    Excel 2003
    Posts
    18

    Re: Macro return First and Last dates in visible cells

    G'day Mick,

    Thank you for the suggested macro. Appreciate your prompt response too.

    Regards,

    Yogi

+ 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