MrKowz
Well-known Member
- Joined
- Jun 30, 2008
- Messages
- 6,653
- Office Version
- 365
- 2016
- Platform
- Windows
Good afternoon!
I'm in the process of optimizing a spreadsheet and have an unconventional need to cause a circular reference.
In my UDF, I have one argument that must be above a certain date if another condition in my formula holds true. If it is not above a certain date, it is automatically adjusted to the date.
To explain the logic, I have a variable "DOC" and a variable "LOC". If LOC contains "SEA", "BOARDWALK", or "CYPRESS", then DOC must be greater than or equal to 12/1/89. If DOC is not greater than or equal to 12/1/89, then DOC needs to be adjusted to that date when the above condition is met.
DOC and LOC are dimmed as range.
When I try to run this code, I get a #Value! error, but if I change the first line to be If DOC < DateSerial(1989,12,1) And ..., the code works fine.
I'm wanting to avoid running this as a Sub, but I'm wanting to see if anyone knows a workaround.
Thanks in advance!
I'm in the process of optimizing a spreadsheet and have an unconventional need to cause a circular reference.
In my UDF, I have one argument that must be above a certain date if another condition in my formula holds true. If it is not above a certain date, it is automatically adjusted to the date.
To explain the logic, I have a variable "DOC" and a variable "LOC". If LOC contains "SEA", "BOARDWALK", or "CYPRESS", then DOC must be greater than or equal to 12/1/89. If DOC is not greater than or equal to 12/1/89, then DOC needs to be adjusted to that date when the above condition is met.
DOC and LOC are dimmed as range.
Code:
If DOC <= DateSerial(1989, 12, 1) And (InStr(UCase$(LOC), "SEA") > 0 Or InStr(UCase$(LOC), "BOARDWALK") > 0 Or InStr(UCase$(LOC), "CYPRESS") > 0) Then
DateOfParticipation = DateSerial(1990, 1, 1)
DOC.Value = DateSerial(1989, 12, 1)
MsgBox "The Date of Credited Service has been adjusted to 12/1/1989", vbOKOnly, "Date of Credited Service"
Else
When I try to run this code, I get a #Value! error, but if I change the first line to be If DOC < DateSerial(1989,12,1) And ..., the code works fine.
I'm wanting to avoid running this as a Sub, but I'm wanting to see if anyone knows a workaround.
Thanks in advance!