mercredi 26 mars 2014

how to find cells with "#VALUE!" in EXCEL 2010 VBA


Vote count:

0




I need to find the max value in a column by EXCEL 2012 VBA. Some cells have "#VALUE!". My code does not work.



Sub find_max()
Dim rng As Range
Dim dblMax As Double
dblMax = 0
Set rng = Range("A2:A11")
For Each cell In rng
If (cell.Value <> "#VALUE!") Then // error ! type mismatch
If dblMax < CDbl(cell.Value) Then
dblMax = CDbl(cell.Value)
End If
End If
Next cell
MsgBox dblMax
End Sub


Any help would be appreciated.



asked 1 min ago






Aucun commentaire:

Enregistrer un commentaire