Home |
Search |
Today's Posts |
#12
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Either check for the error:
if iserror(range("c13").value) then 'do what an error would do else if range("c13").value = "BOCES" then 'do ... end if end if or use the .text property: if range("c13").text = "BOCES" then "EnigmaCDE <" wrote: I am having trouble referencing a cell (or range) .value property from a cell that is returning #N/A (Error 2042) as a result of a failed formula. The following code fails (sometimes): If Range("C13").value = "BOCES" THEN .... END IF Cell C13 has a VLookup formula that sometimes returns #N/A instead of a valid lookup value. Oddly enough when the lookup is successful then the content of Cell C13 is "text" and the code works. However, when the formula is unsuccessful then it returns #N/A (Error 2042) which is an "error object" instead of "text". Consequently my code raises an "error 13 - type mismatch". I'm suprised to find a function that can change it's return type on the fly. Anyway here is how I was able to make it work. Dim MyValue as variant MyValue = Range("C13").value if MyValue = "BOCES" THEN ... END IF Does anyone have a better way to get around this problem???? --- Message posted from http://www.ExcelForum.com/ -- Dave Peterson |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
How do i enable "Group" & "Ungroup" in a protected sheet | Excel Discussion (Misc queries) | |||
Excel - Golf - how to display "-2" as "2 Under" or "4"as "+4" or "4 Over" in a calculation cell | Excel Discussion (Misc queries) | |||
Excel "Move or Copy" and "Delete" sheet functions | Excel Worksheet Functions | |||
How do i enable "Group" & "Ungroup" in a protected sheet | Excel Discussion (Misc queries) | |||
Range only works when Sheet Name is "Sheet1" | Excel Programming |