Results 1 to 10 of 18

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

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Administrator Excel Fox's Avatar
    Join Date
    Mar 2011
    Posts
    1,401
    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

  2. #2
    Member
    Join Date
    Dec 2012
    Posts
    78
    Rep Power
    14
    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

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
  •