Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Newbie: MsgBox, etc

Hi all;


I'm writing a code for a macro in ms excel 2000 and I'm having some
troubles with MsgBox. Here is an example of the code:


Public Function RCL(PLI As Single, RMA As Single)


If RMA 49 And RMA < 71 Then
RCL = 0.91568 * (1 - Exp(-Exp(-1.8956) * (PLI - 1)))


Else
YesNo = MsgBox("RMA out of range!", vbYesNo)
Select Case YesNo
Case vbYes
RCL = 0.75624 * (1 - Exp(-Exp(-1.070025) * (PLI - 1)))
End


Case vbNo
MsgBox "Error"
End


End Select
End If
End Function


.............
After pressing YES/NO I want to MsgBox doesn't show up more than one
time. In the current situation, when I enter a value out of range, the
message appear several times and I have to press OK until I get some
result


Any hint?

Thanks

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 45
Default Newbie: MsgBox, etc

The code below seems fine. It ran okay on my machine. Look at the code that
calls the function; there may be something there that's recalling the
function.

" wrote:

Hi all;


I'm writing a code for a macro in ms excel 2000 and I'm having some
troubles with MsgBox. Here is an example of the code:


Public Function RCL(PLI As Single, RMA As Single)


If RMA 49 And RMA < 71 Then
RCL = 0.91568 * (1 - Exp(-Exp(-1.8956) * (PLI - 1)))


Else
YesNo = MsgBox("RMA out of range!", vbYesNo)
Select Case YesNo
Case vbYes
RCL = 0.75624 * (1 - Exp(-Exp(-1.070025) * (PLI - 1)))
End


Case vbNo
MsgBox "Error"
End


End Select
End If
End Function


.............
After pressing YES/NO I want to MsgBox doesn't show up more than one
time. In the current situation, when I enter a value out of range, the
message appear several times and I have to press OK until I get some
result


Any hint?

Thanks


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 692
Default Newbie: MsgBox, etc

Functions may not be the best place for a msgbox. I'm not even sure if they
will really work there.
Another factor is that a function won't recalculate until one of its input
values changes unless you put Volatile into the code (not sure how that is
supposed to go in), but go in it must to make it fire every time the
worksheet re-calculates.

What you might consider is a worksheet change event to fire only when one of
the cells feeding RMA is changed. Put in the condition and call the msgbox
from there.

--
steveB

Remove "AYN" from email to respond
wrote in message
oups.com...
Hi all;


I'm writing a code for a macro in ms excel 2000 and I'm having some
troubles with MsgBox. Here is an example of the code:


Public Function RCL(PLI As Single, RMA As Single)


If RMA 49 And RMA < 71 Then
RCL = 0.91568 * (1 - Exp(-Exp(-1.8956) * (PLI - 1)))


Else
YesNo = MsgBox("RMA out of range!", vbYesNo)
Select Case YesNo
Case vbYes
RCL = 0.75624 * (1 - Exp(-Exp(-1.070025) * (PLI - 1)))
End


Case vbNo
MsgBox "Error"
End


End Select
End If
End Function


............
After pressing YES/NO I want to MsgBox doesn't show up more than one
time. In the current situation, when I enter a value out of range, the
message appear several times and I have to press OK until I get some
result


Any hint?

Thanks



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Newbie: MsgBox, etc

You could write this recursively but what will be the value that will change
each iteration, and how will we know when to stop?

--

HTH

RP
(remove nothere from the email address if mailing direct)


wrote in message
oups.com...
Hi all;


I'm writing a code for a macro in ms excel 2000 and I'm having some
troubles with MsgBox. Here is an example of the code:


Public Function RCL(PLI As Single, RMA As Single)


If RMA 49 And RMA < 71 Then
RCL = 0.91568 * (1 - Exp(-Exp(-1.8956) * (PLI - 1)))


Else
YesNo = MsgBox("RMA out of range!", vbYesNo)
Select Case YesNo
Case vbYes
RCL = 0.75624 * (1 - Exp(-Exp(-1.070025) * (PLI - 1)))
End


Case vbNo
MsgBox "Error"
End


End Select
End If
End Function


............
After pressing YES/NO I want to MsgBox doesn't show up more than one
time. In the current situation, when I enter a value out of range, the
message appear several times and I have to press OK until I get some
result


Any hint?

Thanks



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
Real Newbie newbie question Dave New Users to Excel 0 January 10th 07 07:55 PM
Newbie, msgbox Bmj Excel Programming 4 October 4th 04 10:10 AM
MsgBox Ed Excel Programming 3 November 23rd 03 05:44 PM
msgbox Marcus Excel Programming 3 November 19th 03 11:35 PM
MsgBox redmad Excel Programming 1 August 1st 03 12:18 AM


All times are GMT +1. The time now is 05:27 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"