LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 13
Default Worksheet events problem

Hi,

I have built simple calculator based on sheet cells, for example B5 and
B7, and two OptionButtons 'addition' and 'subtraction'; outcome is B9
cell. Code for these operation is in Module:

---------------------------------------------------------------------------------------
Public Function MyFun1(a As Double, b As Double, c As Double)

MyFun1 = a + c * b

End Function
---------------------------------------------------------------------------------------

In Sheet1 Module is code for OptionButtons events

----------------------------------------------------------------------------------------
Dim x As Double
Dim y As Double
Dim z As Double

Private Sub OptionButton1_Click()
Call MyFun2
End Sub

Private Sub OptionButton2_Click()
Call MyFun2
End Sub

Private Sub MyFun2()

x = Range("B5").Value
y = Range("B7").Value

Select Case True

Case OptionButton1.Value
z = MyFun1(x, y, 1)
Range("B9") = z

Case OptionButton2.Value
z = MyFun1(x, y, -1)
Range("B9") = z
End Select

End Sub
----------------------------------------------------------------------------------------
When I change value in B5 or B7, in B9 is old result. I get corret
outcome just after I switch OptionButtons. What kind of Worksheet
events, Change or Calculate, to use and how, when I want to get always
proper result alter I change value in B5 or B7?

Regards

Dan

 
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
Worksheet Events DCSwearingen Excel Discussion (Misc queries) 2 May 24th 06 10:42 PM
Worksheet events agarwaldvk[_33_] Excel Programming 0 October 4th 04 10:41 PM
Worksheet events agarwaldvk[_32_] Excel Programming 1 October 4th 04 09:08 AM
Events for a Protected Worksheet jpendegraft[_18_] Excel Programming 2 September 6th 04 04:11 PM
Events problem Stuart[_5_] Excel Programming 6 July 8th 04 09:10 PM


All times are GMT +1. The time now is 02:30 PM.

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

About Us

"It's about Microsoft Excel"