I am working with Excel 2010.
I want to convert a given date from format mm/dd/yyyyto formatWyy"weeknumber"
For example, it 4/10/2017will W1715, since this is week 15 of 2017.
Below is an image of an excel table I'm working on. I want to convert the dates in a column LT Verification - Planned Dateto the week number format mentioned above in a column LT Verification - Planned Week Numbers.
Edit: since this is part of a larger VBA process, I need it to be in VBA, not in the cell formula.
I wrote the following code:
Public Sub WeekNumbers()
Dim lastRow As Integer
lastRow = Range("A1:AZ1").Find("*", , , , xlByRows, xlPrevious).Row
Dim myRange As Range
Set myRange = Range("A1:AZ1" & lastRow)
Dim myCell As Range
For Each myCell In myRange
myCell.Offset(0, 1).Value = "W" & Right(Year(myCell.Value), 2) & Application.WorksheetFunction.WeekNum(myCell.Value)**
Next myCell
End Sub
This code gives me an error in myCell.Offset(0, 1).Value = "W" & Right(Year(myCell.Value), 2) & Application.WorksheetFunction.WeekNum(myCell.Value)
Excel, . , , , , .
, . , . , .
, .
, (A B Z...)
