I apologize for the newb question but have not found a solution online. I am trying to do a simple if-then statement on date ranges in VBA. My code (not working) thus far:
LR = 52
Set rngData = Range("D2:D" & LR)
'define the data range to evaluate
For Each rngCell In rngData
Select Case rngCell.Value
Case Val(Range("'Some_dates'!O8").Value) To Val(Range("'Some_dates'!P8").Value): rngCell.Value = Range("'Some_dates'!N8").Value
Case Val(Range("'Some_dates'!O9").Value) To Val(Range("'Some_dates'!P9").Value): rngCell.Value = Range("'Some_dates'!N9").Value
Case Val(Range("'Some_dates'!O10").Value) To Val(Range("'Some_dates'!P10").Value): rngCell.Value = Range("'Some_dates'!N10").Value
Case Val(Range("'Some_dates'!O11").Value) To Val(Range("'Some_dates'!P11").Value): rngCell.Value = Range("'Some_dates'!N11").Value
Case Else: rngCell.Value = "Outside date ranges"
End Select
Next rngCell
The output for all the cells is "Outside date ranges", which means it is choosing the "else" value for all the cells in rngData, which is incorrect.
Cells O8:P11 in the 'Some_dates' worksheet define four date ranges (start is column O and end is column P). These are dates that can look like numbers or dates depending on how you format the cell. Column N in the 'Some_dates' worksheet has labels for each date range.
Any help is appreciated!