Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 789
Default PRESENTING MSGBOX ONCE ONLY

Hi
I can't see anything in the code you have shown which will make the
message box appear more than once. The problem is then with the code
calling this function. Can you show us the code which uses this
function?
It might help to change your function a little too and separate the
test and the message box:

Function TST(Rng As Range) as Boolean
Dim AR As Range
Set AR = Selection
If AR.Cells.Count < Rng.Cells.Count Then
TST = False
Else
TST = True
End If
End Function

In your calling code you would now have

If TST(Rng) = True then
'your code
Else
MsgBox "Activecells' and the Selection's ranges" & vbNewLine & _
" should be of the Exactly Same Size."
End if

regards
Paul

On Jan 11, 11:07*am, Faraz A. Qureshi
wrote:
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


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Presenting Excel charts kippers Excel Discussion (Misc queries) 1 April 8th 09 02:03 PM
Help with presenting data in å chart norway Charts and Charting in Excel 1 August 15th 07 09:04 PM
Presenting two percentages Omar Excel Discussion (Misc queries) 2 August 2nd 07 04:58 AM
Presenting Subtotals only Tom Excel Discussion (Misc queries) 2 April 12th 06 01:46 PM
Determining and presenting unique entries? [email protected] Excel Programming 3 December 7th 04 03:40 PM


All times are GMT +1. The time now is 03:24 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"