View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Faraz A. Qureshi Faraz A. Qureshi is offline
external usenet poster
 
Posts: 211
Default PRESENTING MSGBOX ONCE ONLY

In the following code when the TST(Rng) function is applied upon four cells
simply (i.e. by Ctrl+Enter), while Rng selected for the same being cells not
equal to 4 in number, results into reappearing of a msgbox 4 times, unless
the function is applied as an array formula.

How to have the same presenting the message:

"Activecells' and the Selection's ranges should be of the Exactly Same Size."

be presented only once and TST returning a zero?

Function TST(Rng As Range)
Dim AR As Range
Set AR = Selection
If AR.Cells.Count < Rng.Cells.Count Then
MsgBox "Activecells' and the Selection's ranges" & vbNewLine & _
" should be of the Exactly Same Size."
Exit Function
Else
TST = "OK"
End If
End Function

--
Thanx in advance,
Best Regards,

Faraz