Vba to return week numbers in Excel

hi all,

Has anyone any idea how to get VBA to give the current week number?

I know i can use the analysis toolpak in excel but i need this form I'm creating to give me the correct week number even if the analysis toolpak isn't installed on a machine. does anyone know of a workaround?





Here the code to do this. Other examples on the following link

Function VBAWeekNum(D As Date, FW As Integer) As Integer
    VBAWeekNum = CInt(Format(D, "ww", FW))
End Function

(for formulas, depending on your country, you might have to change ; with , or the opposite

Other excel answers



You can find similar Excel Questions and Answer hereunder

1) How to do workbook protection with VBA in Excel

2) Here a explanation about the global seek function in VBA. Goal Seek is another tool under What If analysis that does a unique function as Scenario Manager.

3) How can I get users to select a file for processing using my macro?

4) I have a macro that takes a lot of time for execution - how can I keep the user informed that the macro is running?

5) How to do worksheet protection with VBA in Excel

6) How can I find the last used cell in a Column in VBA?

7) How can I add a legend to a chart using VBA?

8) Line break in vba message box in Excel

9) How to rename multiple sheets easily with VBA

10) How can I set up ListBox using VBA to allow users to select multiple values?


Here the previous and next chapter