+ Reply to Thread
Results 1 to 3 of 3

vba use today's date

  1. #1
    Registered User
    Join Date
    01-29-2019
    Location
    London
    MS-Off Ver
    2013
    Posts
    10

    vba use today's date

    Hi,

    I found this vba code

    Function FileCountDate(Path As String, FileType As String) As Long


    Dim strTemp As String
    Dim lngCount As Long


    Application.Volatile

    strTemp = Dir(Path & FileType)
    Do While strTemp <> ""
    If Format(FileDateTime(Path & strTemp), "dd.mm.yyyy") = "03/04/2019" Then
    lngCount = lngCount + 1
    End If
    strTemp = Dir
    Loop
    FileCountDate = lngCount

    End Function

    which works fine, how can I change the code instead of "03/04/2019" to use today's date, so each day when I open the file I will not have to modify the date, I have tried few things but I have not managed to make it work.

    Please let me know.

    Thank you.

  2. #2
    Registered User
    Join Date
    01-29-2019
    Location
    London
    MS-Off Ver
    2013
    Posts
    10

    Re: vba use today's date

    Thanks for reading, found the fix

    If Int(FileDateTime(Path & strTemp)) = Date Then

  3. #3
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,331

    Re: vba use today's date

    In future....Please read the forum rules...here
    Your post does not comply with # 2...
    2. Programming code must be enclosed in code tags to improve readability. (A, Z)
    Please Login or Register  to view this content.
    (or use the # button)
    Good Luck
    I don't presume to know what I am doing, however, just like you, I too started somewhere...
    One-day, One-problem at a time!!!
    If you feel I have helped, please click on the star to left of post [Add Reputation]
    Also....add a comment if you like!!!!
    And remember...Mark Thread as Solved.
    Excel Forum Rocks!!!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 10
    Last Post: 09-06-2023, 08:19 PM
  2. [SOLVED] Finding Dates Within Date Range (Based on Today's Date) Whilst Matching Name?
    By EduardStoo in forum Excel Formulas & Functions
    Replies: 9
    Last Post: 02-08-2019, 10:31 AM
  3. Replies: 5
    Last Post: 12-01-2015, 02:36 PM
  4. [SOLVED] Sumif from date (Today or greater than today) to last date
    By thilag in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 11-23-2015, 03:53 AM
  5. [SOLVED] Formula to compare date (including month and year) from a listed date to today's date
    By mhewitson15 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 11-11-2014, 05:31 PM
  6. condit. format: If date in cell = today, display "Today"
    By ratkins in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 02-14-2013, 01:33 PM
  7. Replies: 6
    Last Post: 08-08-2011, 08:32 AM

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