Hi
This function will test whether the row has a blank cell in the columns:
Function testBlanks(intRow As Integer, intCol1 As Integer, _
Optional intCol2 As Integer, _
Optional intCol3 As Integer, _
Optional intCol4 As Integer) As Boolean
Dim ans As Single, strCalc As String
'What we are aiming for: Evaluate("=ISBLANK(A1)*ISBLANK(B1)*ISBLANK(C1)")
strCalc = "=ISBLANK(" & Cells(intRow, intCol1).Address & ")"
If intCol2 > 0 Then
strCalc = strCalc & "*ISBLANK(" & Cells(intRow, intCol2).Address & ")"
End If
If intCol3 > 0 Then
strCalc = strCalc & "*ISBLANK(" & Cells(intRow, intCol3).Address & ")"
End If
If intCol4 > 0 Then
strCalc = strCalc & "*ISBLANK(" & Cells(intRow, intCol4).Address & ")"
End If
testBlanks = (Evaluate(strCalc) = 1)
End Function
Example:
sub test
MsgBox testBlanks(12, 2, 4, 6)
end sub
This would test for cells B12, D12 and F12 being blank, and return true if they were.
The input is TestBlanks (row, col1, col2, col3, col4) - columns 2-4 are optional.
Hope this helps.
You just need to read the list box and pass on the columns to test.
Best regards, Rob.
Bookmarks