I have a text box that populates "dd/mm/yyyy" on a button press. Is there a way to populate the next text box with that dates calender week "ww" where it changes dynamically?
I have a text box that populates "dd/mm/yyyy" on a button press. Is there a way to populate the next text box with that dates calender week "ww" where it changes dynamically?
There are few ways to calculate week number from date.
Which standard are you using? Excel standard WEEKNUM function, ISOWEEKNUM function, or other variation? And what day of week is start of week? Monday/Sunday?
Note: ISOWEEKNUM is not available in Excel 2010 (introduced on Excel 2013) and always uses Monday as first day of week.
ISOWEEKNUM will account for week crossing over one year to next. Ex: 1/1/2021 will belong to Week 53 of 2020. Where as WEEKNUM(date,2) will give first 3 days of 2021 as week 1 of 2021.
At any rate, I'd recommend that you calculate calendar week at same time as you fill the text box on button press. Using DateSerial(year, month, day) function along with Application.ISOWEEKNUM or WEEKNUM.
?Progress isn't made by early risers. It's made by lazy men trying to find easier ways to do something.?
― Robert A. Heinlein
I took your advice and calculated the week at the same time and ended up with this
That seems to do the job, but without the dynamic changing. I could live with that.Please Login or Register to view this content.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks