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

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.
Yes, so if you write = jec(A1,5) , it gives you the date of Friday
 
Upvote 0

Forum statistics

Threads
1,215,771
Messages
6,126,799
Members
449,337
Latest member
BBV123

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