简体   繁体   中英

VBA Macro WeekNum not defined

I'm trying to concancenate Year with WeekNum in VBA. But it said that the WeekNum Sub or Function does not defined. How can I solve this? Here is my code :

For lrow = EndRow To 2 Step -1
    CurrentSheet.Cells(lrow, "AC").Value = _
    CONCATENATE(Year(CurrentSheet.Cells(lrow, "K").Value), _
    "/", Text(WeekNum(CurrentSheet.Cells(lrow, "K").Value), "00"))
Next lrow

*Note that I do this a line only, just using _ just for reading capability

Thanks! :)

Add Application.WorksheetFunction in front:

For lrow = EndRow To 2 Step -1
    CurrentSheet.Cells(lrow, "AC").Value = _
    CONCATENATE(Year(CurrentSheet.Cells(lrow, "K").Value), _
    "/", Text(Application.WorksheetFunction.WeekNum(CurrentSheet.Cells(lrow, "K").Value), "00"))
Next lrow

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM