Unicam
New Member
- Joined
- Mar 22, 2006
- Messages
- 31
Hello everyone,
Here at work we use complex VBA scripts that import data from files from last week to compare them to this week's results. I have the scripts look up the files by the current year and week number, that's how they are stored.
To determine the week number I use this function:
I simply use 'WeekNummer(Date) - 1' to let the script determine last week's number.
To determine the year number I use this:
Both codes work fine, but this is always a problem during the first week of the year. The script obviously doesn't look for the right files and I cannot find a way around this anywhere. This always means I have to merge files manually which is a frustrating and annoying task. Can anyone tell me if there is a way to determine the 'REAL' week and year number of last week?
Any help would be greatly appreciated!
Here at work we use complex VBA scripts that import data from files from last week to compare them to this week's results. I have the scripts look up the files by the current year and week number, that's how they are stored.
To determine the week number I use this function:
Code:
Public Function WeekNummer(InDate As Date) As Long
ISOWeeknum = DatePart("ww", dt, vbMonday, vbFirstFourDays)
If ISOWeeknum > 52 Then
If DatePart("ww", dt + 7, vbMonday, vbFirstFourDays) = 2 Then
ISOWeeknum = 1
End If
End If
End Function
I simply use 'WeekNummer(Date) - 1' to let the script determine last week's number.
To determine the year number I use this:
Code:
Format(Now(), "yyyy")
Both codes work fine, but this is always a problem during the first week of the year. The script obviously doesn't look for the right files and I cannot find a way around this anywhere. This always means I have to merge files manually which is a frustrating and annoying task. Can anyone tell me if there is a way to determine the 'REAL' week and year number of last week?
Any help would be greatly appreciated!