+ Reply to Thread
Results 1 to 17 of 17

Finding current date

  1. #1
    Forum Contributor
    Join Date
    10-31-2006
    Location
    Oslo, Norway
    MS-Off Ver
    MS 365 Business
    Posts
    286

    Finding current date

    I have a worksheet with large number of rows with dates; one date per row.
    I need a macro to find todays date.
    Can anyone help me with this procedure ?

    Saturn

  2. #2
    Forum Moderator zbor's Avatar
    Join Date
    02-10-2009
    Location
    Croatia
    MS-Off Ver
    365 ProPlus
    Posts
    15,592

    Re: Finding current date

    Something like this:

    =INDEX(A:A, MATCH(TODAY(), B:B, 0))

    where are dates in B column

  3. #3
    Registered User
    Join Date
    05-04-2010
    Location
    Norway
    MS-Off Ver
    Excel 365
    Posts
    30

    Re: Finding current date

    Quote Originally Posted by Saturn View Post
    I have a worksheet with large number of rows with dates; one date per row.
    I need a macro to find todays date.
    Can anyone help me with this procedure ?

    Saturn
    I'll answer this in Norwegian as well as English

    If I understand you correctly, you don't need a macro, du can use one of the bulit-in formulas in Excel:

    Please Login or Register  to view this content.
    The actual cell will then always show todays date when you open the file.

    Hvis jeg forstår deg riktig, så trenger du ikke en makro, du kan bruke en av Excels innebyggede formler:

    Please Login or Register  to view this content.
    Så vil den aktuelle cellen alltid vise dags dato når du åpner filen.

  4. #4
    Forum Contributor
    Join Date
    10-31-2006
    Location
    Oslo, Norway
    MS-Off Ver
    MS 365 Business
    Posts
    286

    Re: Finding current date

    Thank you zbor.

    But I am interesting how the VBA procedure is written.

  5. #5
    Valued Forum Contributor
    Join Date
    06-19-2010
    Location
    Holywell, N Wales, UK
    MS-Off Ver
    Excel 2013
    Posts
    470

    Re: Finding current date

    build on this?
    Please Login or Register  to view this content.
    where fndnow is a Range

  6. #6
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Finding current date

    Try this
    Please Login or Register  to view this content.
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  7. #7
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: Finding current date

    Please Login or Register  to view this content.



  8. #8
    Forum Contributor
    Join Date
    10-31-2006
    Location
    Oslo, Norway
    MS-Off Ver
    MS 365 Business
    Posts
    286

    Re: Finding current date

    I think I have expressed myself unclear in this thread. Appology to everyone who has answered.

    The worksheet has a lot of rows with dates in each row. (The dates are accending down the w/s).
    When I am at the top of the worksheet I want to have a button (linked to a macro) which sends me to the row with todays date.
    How is the VBA-procedure written ?

  9. #9
    Forum Guru (RIP) Marcol's Avatar
    Join Date
    12-23-2009
    Location
    Fife, Scotland
    MS-Off Ver
    Excel '97 & 2003/7
    Posts
    7,216

    Re: Finding current date

    Assign Roys' macro to your button

  10. #10
    Forum Contributor
    Join Date
    10-31-2006
    Location
    Oslo, Norway
    MS-Off Ver
    MS 365 Business
    Posts
    286

    Re: Finding current date

    It doesn't work.
    I get the messagebox which tells me: 19.06.2011 is not listed.
    I want the macro to send me to the row with todays date.

    Saturn

  11. #11
    Forum Expert
    Join Date
    11-29-2010
    Location
    Ukraine
    MS-Off Ver
    Excel 2019
    Posts
    4,168

    Re: Finding current date

    hi, Saturn, try a bit modified Roy's code:
    Please Login or Register  to view this content.
    it should work as expected. If it does not, try to change this:

    Please Login or Register  to view this content.
    to this:

    Please Login or Register  to view this content.
    Last edited by watersev; 06-19-2011 at 08:06 AM.

  12. #12
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: Finding current date

    The method 'Find' never gives me a result finding a date.(no matter using xlvalue, xlformula,xlwhole,xlpart, format(date,"dd-mm-yyyy"), formatdatetime(date,xldategeneral) or formatdatetime(date,xlshortdate) or a numerical value using 1*Date)

    @watersev
    The addition "*"... "*" to Date doesn't seem logical, considering the use of the argument 'xlwhole'.
    Last edited by snb; 06-19-2011 at 08:11 AM.

  13. #13
    Forum Expert
    Join Date
    11-29-2010
    Location
    Ukraine
    MS-Off Ver
    Excel 2019
    Posts
    4,168

    Re: Finding current date

    @snb, I do not see any problem with it in my case, run "x"
    Attached Files Attached Files

  14. #14
    Forum Guru (RIP) Marcol's Avatar
    Join Date
    12-23-2009
    Location
    Fife, Scotland
    MS-Off Ver
    Excel '97 & 2003/7
    Posts
    7,216

    Re: Finding current date

    I suspect that it is the regional settings that you are using that causes ".Find" to fail.

    What regional settings are you using, and how is your system date formatted?

    Post a sample workbook with a typical selection of your data, and state your date settings.

    This can take forever to sort out without this information.

  15. #15
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: Finding current date

    @watersev

    I did, only perceiving the messagebox.

    BTW, I'd prefer
    Please Login or Register  to view this content.

  16. #16
    Forum Guru (RIP) Marcol's Avatar
    Join Date
    12-23-2009
    Location
    Fife, Scotland
    MS-Off Ver
    Excel '97 & 2003/7
    Posts
    7,216

    Re: Finding current date

    This should work regardless of formatting and regional settings (see the attached)
    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by Marcol; 06-19-2011 at 10:00 AM. Reason: Added attachment
    If you need any more information, please feel free to ask.

    However,If this takes care of your needs, please select Thread Tools from menu above and set this topic to SOLVED. It helps everybody! ....

    Also
    اس کی مدد کرتا ہے اگر
    شکریہ کہنے کے لئے سٹار کلک کریں
    If you are satisfied by any members response to your problem please consider using the small Star icon bottom left of their post to show your appreciation.

  17. #17
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: Finding current date

    To get the method 'Find' performing I need to convert all dates to numericals:

    Please Login or Register  to view this content.

+ 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