Thread: Blank Cell
View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
IanKR IanKR is offline
external usenet poster
 
Posts: 97
Default Blank Cell

I am using VLOOKUP to find and enter an associated time value in a
cell (D2) that is referencing another cell (D1). D1 generally blank
until a text choice is made using a drop-down list. I would like to
not have the #N/A message in D2 when D1 is blank. I could put in a
generic character (such as ?) and use the IF function. However, I was
wondering if there is a way determine a blank cell directly using the
IF function?


If it helps, I use a UDF to return zero (or you could change this value to
suit yourself) if VLOOKUP returns #N/A:

Function NewVLookup(Value As Variant, Table As Variant, _
ColIndex As Integer, RangeLookup As Boolean) As Variant
With Application
If .IsNA(.VLookup(Value, Table, _
ColIndex, RangeLookup)) Then
NewVLookup = 0 ' <========== or put your own value here
Else
NewVLookup = .VLookup(Value, Table, ColIndex, RangeLookup)
End If
End With
End Function