Results 1 to 10 of 16

Thread: Find Quarter Month From Date In Excel

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Administrator Admin's Avatar
    Join Date
    Mar 2011
    Posts
    1,123
    Rep Power
    10
    Hi

    I did a small test and the average time taken for Hasseb's and Rick's function are .22 secs and .15 secs respectively.


    Here is how I did in a blank workbook

    Code:
    Sub Haseeb()
        Dim t
        ClearAllCells
        t = Timer
        With Range("b1:b10000")
            .FormulaR1C1 = "=COUPNCD(rc[-1],""1/1/""&YEAR(rc[-1])+1,4,1)-1"
        End With
        Debug.Print Format(Timer - t, "00.00")
    End Sub
    Sub Rick()
        Dim t
        ClearAllCells
        t = Timer
        With Range("b1:b10000")
            .FormulaR1C1 = "=1*(LOOKUP(MONTH(rc[-1])+2,{3,6,9,12})&""/13"")"
        End With
        Debug.Print Format(Timer - t, "00.00")
    End Sub
    Sub ClearAllCells()
        Range("b1:b10000").ClearContents
    End Sub
    Sub FillDates()
        Range("a1") = DateSerial(1950, 1, 1)
        Range("a1:a10000").DataSeries , 3, 3
    End Sub
    Cheers !

    Excel Range to BBCode Table
    Use Social Networking Tools If You Like the Answers !

    Message to Cross Posters

    @ Home - Office 2010/2013/2016 on Win 10 (64 bit); @ Work - Office 2016 on Win 10 (64 bit)

  2. #2
    Forum Guru Rick Rothstein's Avatar
    Join Date
    Feb 2012
    Posts
    662
    Rep Power
    14
    Okay, I guess that is a fair way to measure the time difference. My guess is the actual percentage difference between the two functions is probably larger than your numbers show because I would guess there is some "fixed" interface time between the VB world and the worksheet world that both formula assigments experience equally... subtracting that fixed time, whatever it is, from your measured time would yield the actual time to calculate the formulas themselves... the time difference you measured would not change, but the base against which it is measured would decrease making the percentage difference increase. Of course, there is no way to measure that fixed VB to worksheet interface time, so your method is in and of itself is a more than sufficient measuring tool. Thanks for coming up with it and for running the trials using it.

Similar Threads

  1. Replies: 5
    Last Post: 06-15-2013, 12:40 PM
  2. Replace Incorrect Date In Cell To Another Valid Date
    By DARSHANKmandya in forum Excel and VBA Tips and Tricks
    Replies: 2
    Last Post: 03-21-2013, 09:27 PM
  3. Automate Date Changes Within Excel Workbook
    By Danno2cu in forum Excel Help
    Replies: 9
    Last Post: 02-18-2013, 11:39 PM
  4. How To Change Date Format in Excel
    By Oh!Calcutta in forum Excel Help
    Replies: 1
    Last Post: 11-01-2012, 09:36 PM
  5. Week Of The Month
    By Excel Fox in forum Excel and VBA Tips and Tricks
    Replies: 2
    Last Post: 02-22-2012, 08:35 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •