Home |
Search |
Today's Posts |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
You could also use other errors. So your unequal ranges could be
if MyRange1.Cells.Count < MyRange2.Cells.Count then myFunc = CvErr(xlErrRef) End Function End If and use #Value for some otherv error. Your user instructions could tell the user what each error means. -- HTH Bob Phillips ... looking out across Poole Harbour to the Purbecks (remove nothere from the email address if mailing direct) "Jaap Versteegh" wrote in message ... Hi use the CVErr function in the VBA help Thanks for the response Frank, but how would this help ? Problem: A vba (worksheet)function needs 2 ranges as parameters, but they both need to be of the same size. I would like to notify the user when they aren't rather than just return "#VALUE" in the cell. So something like: function MyFunc (MyRange1 as Range, MyRange2 as Range) On Error GoTo ErrorHandler if MyRange1.Cells.Count < MyRange2.Cells.Count then Err.Raise 1000, "MyFunc", "Ranges not of same size !" end if ' Do the stuff the function does here ! Exit Function ErrorHandler: ' Now here I would like to tell the user of this function what the problem is ... MsgBox Err.Description ' This however causes problems when entering the function from the formula bar after ' clicking the equal sign - the function is invoked before the second range has been entered ' completely, so the ranges are not of the same size (yet). The message box is displayed so ' the user can't complete the entry of the second parameter.... ' Re-raise the error so the function will return #VALUE ! Err.Raise 1000 End Function TIA for any further suggestions... Regards Frank |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Error Handling #N/A with AVERAGE Function - Average of values in Row | Excel Worksheet Functions | |||
Error handling | Excel Programming | |||
Error Handling | Excel Programming | |||
Error Handling | Excel Programming | |||
Error handling | Excel Programming |