Michele317
New Member
- Joined
- Apr 29, 2024
- Messages
- 20
- Office Version
- 365
- Platform
- Windows
Hello everyone,
as stated in the title of the thread, I'm having some problem with a VBA Code.
This is the code:
This part of the code checks first if a cell contains a certain value ("Holiday", in this case) and, if that's true, it does a VLookup of the date (that is in column 2) in the range F10:F33 of another sheet (the range are the holidays which are not saturday or sunday. So, I have a range of dates for Christmas, Easter, ...), giving back a certain string which can be "Half Holiday" or "Full day Holiday".
I need to know if it's a half day holiday or a full day holiday for formatting purposes.
The problem i'm having is the follow: The iteration with the For cycle seems to works fine, it skips some days (since they are not holidays) and then, when it gets to saturday, it execture the If statment and so: it does the Vlookup, it understands that the date is not in the holiday range (the one containing only Christmas, Easter, ...) and skips to the On Error part of the code.
When it start the new For Cycle iteration, it gives me back the following error "Unable to get the VLookup property of the WorksheetFunction class" which appear when it doesn't find any value. This is also correct, but why the code doesn't execute the On Error part of the code again?
Thank you all in advance
as stated in the title of the thread, I'm having some problem with a VBA Code.
This is the code:
VBA Code:
For i = 3 To 33
If Cells(i, 4) = "Holiday" Then
On Error GoTo nonParty:
tipoFestività = WorksheetFunction.VLookup(Cells(i, 2), sheet_set.Range("F10:F33"), 5, 0)
...
This part of the code checks first if a cell contains a certain value ("Holiday", in this case) and, if that's true, it does a VLookup of the date (that is in column 2) in the range F10:F33 of another sheet (the range are the holidays which are not saturday or sunday. So, I have a range of dates for Christmas, Easter, ...), giving back a certain string which can be "Half Holiday" or "Full day Holiday".
I need to know if it's a half day holiday or a full day holiday for formatting purposes.
The problem i'm having is the follow: The iteration with the For cycle seems to works fine, it skips some days (since they are not holidays) and then, when it gets to saturday, it execture the If statment and so: it does the Vlookup, it understands that the date is not in the holiday range (the one containing only Christmas, Easter, ...) and skips to the On Error part of the code.
When it start the new For Cycle iteration, it gives me back the following error "Unable to get the VLookup property of the WorksheetFunction class" which appear when it doesn't find any value. This is also correct, but why the code doesn't execute the On Error part of the code again?
Thank you all in advance