0
Thanks

A few words of thanks would be greatly appreciated.

getting the week number automatically




I need to get the week number automatically... Let say I enter the date in Cell A2 then I want Cell B5 to show the respective week number. Let say for example if today is 18/8/2010 and week should be 33 I recorded a macro and entered it into sheet1 code but nothing happened... Can someone help me correct this code? Thanks

Sub week2()
    ActiveCell.FormulaR1C1 = "=WEEKNUM(R[-3]C)"
    Range("B6").Select
End Sub
  • Used the command line below;

Sub week2()
    ActiveCell.FormulaR1C1 = "=TRUNC(TRUNC((A1-DATE(YEAR(A1),1,0))+6)/7)"
    Range("B6").Select
End Sub

Solved by rizvisa1
0
Thanks

A few words of thanks would be greatly appreciated.

Ask a question
CCM is a leading international tech website. Our content is written in collaboration with IT experts, under the direction of Jean-François Pillou, founder of CCM.net. CCM reaches more than 50 million unique visitors per month and is available in 11 languages.
This document, titled « getting the week number automatically », is available under the Creative Commons license. Any copy, reuse, or modification of the content should be sufficiently credited to CCM (ccm.net).

Subscribe To Our Newsletter!

The Best of CCM in Your Inbox

Subscribe To Our Newsletter!