Convert date to week number and year

Adam19931

New Member
Joined
Jun 22, 2021
Messages
4
Office Version
  1. 365
Platform
  1. Windows
Hi all, I have a date in textbox frm.Form.txtDelDate on a user form and I am looking for a way to convert this date to a week number in "ww-yyyy" format with the first day of the week being Sunday. Is there a way of doing this in VBA so that it can be added to irow,2 in the code below please?


VBA Code:
With sh
    
        .Cells(irow, 1) = "3T-" & irow - 1
        .Cells(irow, 2) =
        .Cells(irow, 3) = [text(Now(),"DD-MM-YYYY")]
        .Cells(irow, 4) = frmForm.txtDelDate.Value
        .Cells(irow, 6) = frmForm.txtDestName.Value
        .Cells(irow, 7) = frmForm.txtDestLocation.Value
        .Cells(irow, 8) = frmForm.txtRouteID.Value

Thanks in advance for any help
 

Excel Facts

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"
perhaps some variation of
= weekday(#01/02/2023#) & "-" & year(#01/02/2023#)

I think I would pass the textbox date to a variable and use that instead of an actual date or instead of repeating the textbox reference.
 
Upvote 0
Solution

Forum statistics

Threads
1,216,950
Messages
6,133,679
Members
449,825
Latest member
dewy0823

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