OK.
It works fine when I use the frm.myForm.lFreq.caption =
Application.WorksheetFunction.CountBlank(ListRange), but when using the
lFreq.Caption = Application.WorksheetFunction.Dcount(rngList, rngHeader,
rngCriteria), I get a run time error 424 "Object required". What is missing
here?
Frank Krogh
Brad Vontur said:
You could set the value of the Label by just running:
lFreq.Caption = Application.WorksheetFunction.Dcount(rngList, rngHeader, rngCriteria)
Depending on where you put that code, it becomes volatile. For example,
if you put that code in the frmFreqTable_Initialize() event subroutine, it's
only assigned when the form opens. But if you put it in the
Worksheet_Change(Target as Range) event subroutine, the label will update
whenever a cell changes. That would make the code execute often though,
even when unnecessary; which isn't a big deal if your data range is small.
But if it's large enough to make dcount run slowly, you can put something
like this in that change event procedure: