WardenBerret
New Member
- Joined
- Mar 2, 2016
- Messages
- 9
Hi. Glad to be apart of the community even if for a short period :D
So, my problem...
I want to get the weeknumber from a date in a cell using an excel macro.
I have this code right now, but I keep getting a compiler error
The error I get highlights the first .WeekNum expression and it says:
I basically want the output in
to be in the format w.YYWW.5 (YY = last digits of the year, which works! & WW=weeknumber with "0" if the week is between 1 - 9 ,this does not work!)
As I said, the last digit of the year - which is taken from the same Date cell as the weeknumber i want - is working.
Big thanks, best regards.
So, my problem...
I want to get the weeknumber from a date in a cell using an excel macro.
I have this code right now, but I keep getting a compiler error
Code:
If Len(WorksheetFunction.WeekNum(wbThis.Sheets("Availability").Range("C5").Value)) = 1 Then
wbTarget.Sheets("Sheet1").Range("C6") = "w." & Right(Year(wbThis.Sheets("Availability").Range("C5").Value), 2) & "0" & WorksheetFunction.WeekNum(wbThis.Sheets("Availability").Range("C5").Value) & ".5"
Else
wbTarget.Sheets("Sheet1").Range("C6") = "w." & Right(Year(wbThis.Sheets("Availability").Range("C5").Value), 2) & WorksheetFunction.WeekNum(wbThis.Sheets("Availability").Range("C5").Value) & ".5"
End If
The error I get highlights the first .WeekNum expression and it says:
Code:
[COLOR=#222426][FONT=Consolas]Compile error: Variable Required - can't assign this to this expression[/FONT][/COLOR]
I basically want the output in
Code:
wbTarget.Sheets("Sheet1").Range("C6")
As I said, the last digit of the year - which is taken from the same Date cell as the weeknumber i want - is working.
Big thanks, best regards.