Reduce Typing and Tear
I saw my buddy on the next aisle struggling with this mile long formula that breaks every time it is copied down.Wouldn’t it be neat if he just had to choose a couple parameters and it would compute automatically.
Function PutTake(LowDate, HiDate As Date, TheAnswer)
Dim CurCell As Long
Dim AnsCol As Long
Dim DateColLow As Long
On Error GoTo ErrHandles
CurCell = ActiveCell.Row
AnsCol = TheAnswer.Column
DateColLow = LowDate.Column
If Sheets("Detail (Data Entry)").Cells(CurCell, DateColLow) = "" Then
PutTake = 0
Else
If Sheets("Detail (Data Entry)").Cells(CurCell, DateColLow) >= LowDate Then
If Sheets("Detail (Data Entry)").Cells(CurCell, DateColLow + 1) <= HiDate Then
PutTake = Sheets("Detail (Data Entry)").Cells(CurCell, AnsCol)
End If
Else
PutTake = 0
End If
End If
Exit Function
ErrHandles:
PutTake = "Error"
End Function
Orignally, my variable were named things like “daAnswer” and “daNumber” but the guys laughed at my hillbilly names. Remember, this is just an example; your results may vary.
|