You wrote:
"=AlerteDate(C37,Today) is an unusual way of doing a validation check
...snip... Using it this way, it needs to be a function."
But it IS a function.
But I understand what you mean as a minor problem it could be:
After your last message, as a matter of fact, I had a problem: the cell
that contains "Today" was used somewhere else where there was no alert
necessary if some cells had a value later then today: when I opened the
file, I started getting alerts, so I had to create another cell
containing "=today()) reserved for that function.
So now, it is not a problem, because it the user does not change the
wrong date in cell A37, a larger sub will be interrupted, and the user
needs to have the larger sub do its job!
And the last step of that larger sub is to clear the content of the cell
A37.
I know I could do the same inside the larger job, but apart from the
date, the user must enter other values in others cells, and I waited for
the sub to find the date error, I feel it would be a loss of time for
the user as when he/she is alerted right away.
I have done it somewhere else where the error can not be detected before
the sub had run: it is a sub that updates a webquery and compares new
data with data in the spreadsheet. So as soon as the sub detects the
error, it stops.
Back to your quote: "is an unusual way of doing a validation check".
What else could it be?
I have looked at so many tutorial and examples, and I could not clearly
find how to pass values from the spreadsheet to a sub: all examples that
I found looked like: select a cell, or an array, it give values that are
set in the sub.
A simple example taken from the VB HELP:
The following example shows how you might define a procedure with a
parameter array.
Sub AnyNumberArgs(strName As String, ParamArray intScores() As Variant)
Dim intI As Integer
Debug.Print strName; " Scores"
' Use UBound function to determine upper limit of array.
For intI = 0 To UBound(intScores())
Debug.Print " "; intScores(intI)
Next intI
End Sub
The following examples show how you can call this procedure.
AnyNumberArgs "Jamie", 10, 26, 32, 15, 22, 24, 16
AnyNumberArgs "Kelly", "High", "Low", "Average", "High"
Others get the value using a prompt. I do not want that!
So, what if the sub needs values from the spreadsheet?
I have started to find a way by using
ActiveCell.Value,
then moving to another cell with:
ActiveCell.Offset(rowOffset:=1, columnOffset:=0).Activate
and so on. But I find it not very elegant...
Maybe you think this would be too complicated to answer here, but you
might give me a reference where I could study and find how to do it.