Date formats in VB question

KillGorack

New Member
Joined
Jan 23, 2006
Messages
35
Office Version
  1. 2016
Platform
  1. Windows
I have a week number (ISO), and a year. I need to get a date in mm/dd/yyyy on the Monday

for example a system we use provides this;
202308

And would love a bit of code to turn that into
02/20/2023

Not in a cell but with VB code

I'm wracking my brain...
 
One small change:

VBA Code:
Function jec(cell As Variant, day As Integer) As Long
jec = 7 * (Right(cell, 2) - 1) + DateSerial(Left(cell, 4), 1, 4) - Weekday(DateSerial(Left(cell, 4), 1, 4), 2) + day
End Function

Excel Formula:
=jec(A1,1)

As I understand it'll come back with whatever weekday needed, yes?
 
Upvote 0

Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.
Yes, so if you write = jec(A1,5) , it gives you the date of Friday
 
Upvote 0

Forum statistics

Threads
1,215,019
Messages
6,122,707
Members
449,093
Latest member
Mnur

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