Today's Week Number, *Custom Ribbon UI* [VBA]

Martin_H

Board Regular
Joined
Aug 26, 2020
Messages
190
Office Version
  1. 365
Platform
  1. Windows
Hi team,

I am building a custom ribbon UI Workbook.

I am using this (see below) to get Today's Date.
VBA Code:
Function mydate()
mydate = Date
End Function
+
VBA Code:
Sub DATE(control As IRibbonControl, ByRef label)
label = "" & mydate & ""
End Sub

Then I am using this (see below) to get Today's Weekday Name.
VBA Code:
Function myweekdayname()
myweekdayname = WeekdayName(1, False, vbMonday)
End Function
+
VBA Code:
Sub WeekdayName(control As IRibbonControl, ByRef label)
label = "" & myweekdayname & ""
End Sub

Now I would like to get Today's Weeknumber.

Normally I am using this formula =WEEKNUM(TODAY(),21) to get the right Weeknumber (mind the 21 at the end of the formula).

I would like to implement it the same way as the codes above.


Thank you.
Much appreciated.
 

Excel Facts

Format cells as time
Select range and press Ctrl+Shift+2 to format cells as time. (Shift 2 is the @ sign).
One quick and easy way of using worksheet functions in VBA is to put WorksheetFunction. infront of it. Try:

VBA Code:
label = WorksheetFunction.WeekNum(Now, 21)
 
Upvote 0
Solution
One quick and easy way of using worksheet functions in VBA is to put WorksheetFunction. infront of it. Try:

VBA Code:
label = WorksheetFunction.WeekNum(Now, 21)
Thank you Dan.
Much appreciated.
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top