Page 2 of 2 FirstFirst 12
Results 11 to 18 of 18

Thread: Code To Add Date And Seven Day Week Number From Start Of Year

  1. #11
    Member
    Join Date
    Dec 2012
    Posts
    78
    Rep Power
    13
    sorry my apologies...yes now wroks.Thank you

    I`1m new to this so finally i need to use a button for these 2 operations..please how do i assign a button to achieve the result from my previous request in post #6

    thank you

  2. #12
    Member
    Join Date
    Dec 2012
    Posts
    78
    Rep Power
    13
    Please see attached file.....the week number is 53 and it skips week 1...can this be altered please?
    Attached Files Attached Files

  3. #13
    Administrator Excel Fox's Avatar
    Join Date
    Mar 2011
    Posts
    1,402
    Rep Power
    10
    Try this instead...

    Code:
    Sub AddDates() 
        Dim dt  As Date
        
        If IsDate(Range("d10").Value) Then
            dt = Range("d10").Value
            With Range(DateRange)
                .FormulaR1C1 = "=rc[-1]+1"
                .Cells(1) = dt
                .Offset(-1).FormulaR1C1 = "=IF(MOD(COLUMNS(RC4:RC)-1,7)+1=1,ROUNDUP((R[1]C-DATE(YEAR(R[1]C),1,0))/7,0),"""")"
                .Offset(-1).Resize(2) = .Offset(-1).Resize(2).Value
            End With
        End If
        
    End Sub
    Attached Files Attached Files
    A dream is not something you see when you are asleep, but something you strive for when you are awake.

    It's usually a bad idea to say that something can't be done.

    The difference between dream and aim, is that one requires soundless sleep to see and the other requires sleepless efforts to achieve

    Join us at Facebook

  4. #14
    Member
    Join Date
    Dec 2012
    Posts
    78
    Rep Power
    13
    Hi Excel Fox

    Thanks that works great with the buttons...the only issue is if i place 31-12-2012 it has the week number as 53 instead of 1

    Thanks again

  5. #15
    Administrator Excel Fox's Avatar
    Join Date
    Mar 2011
    Posts
    1,402
    Rep Power
    10
    rich, i thought 31-12-2012 should be week number 53. How can it be 1?
    A dream is not something you see when you are asleep, but something you strive for when you are awake.

    It's usually a bad idea to say that something can't be done.

    The difference between dream and aim, is that one requires soundless sleep to see and the other requires sleepless efforts to achieve

    Join us at Facebook

  6. #16
    Member
    Join Date
    Dec 2012
    Posts
    78
    Rep Power
    13
    ADD DATES.xlsmHi Excel fox

    I am sure there is only 52 weeks in a year...please see attached

    This formula gives 52 weeks using the same dates..started with 17/12/2012 =IF(WEEKNUM(D10,21)<>WEEKNUM(C10,21),WEEKNUM(D10,2 1),"")

    Thanks

  7. #17
    Administrator Excel Fox's Avatar
    Join Date
    Mar 2011
    Posts
    1,402
    Rep Power
    10
    rich, there are 365 days in a year, and in a leap year, 366. If one were to assume that the very first day of the year started with the very first weekday, then by the time you reach the 364th day, you would have completed 52 weeks. From that logic, the next day (or two) should be the 53rd week. The question is, do you want to start showing the actual week number, or the index of each 7 day period that 'makes' a week starting from 1st of January?
    A dream is not something you see when you are asleep, but something you strive for when you are awake.

    It's usually a bad idea to say that something can't be done.

    The difference between dream and aim, is that one requires soundless sleep to see and the other requires sleepless efforts to achieve

    Join us at Facebook

  8. #18
    Member
    Join Date
    Dec 2012
    Posts
    78
    Rep Power
    13
    Hi Excel Fox

    Yes you are correct...my apology....Yes week starting from 1st of January (2013,2014,2015 etc..etc..) is what i want please

    Thank you

Similar Threads

  1. Nth Day Of Week Number Using Formula
    By paul_pearson in forum Excel Help
    Replies: 2
    Last Post: 06-16-2013, 06:40 PM
  2. Data Validation For Selecting Date And Week Number
    By paul_pearson in forum Excel Help
    Replies: 8
    Last Post: 06-16-2013, 05:07 AM
  3. Replies: 5
    Last Post: 06-15-2013, 12:40 PM
  4. Date Format From Start Day To End Day
    By PcMax in forum Excel Help
    Replies: 2
    Last Post: 03-10-2013, 02:07 PM
  5. Week Number And Week Start Day of Week
    By Rajesh Kr Joshi in forum Excel Help
    Replies: 4
    Last Post: 10-24-2011, 07:33 PM

Posting Permissions

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