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: 11
Default How to get variables from worksheet code to userform code

In my worksheet, I have buttons to run macros, and I also have a
UserForm. In the worksheet code I have:

Dim Money as Double

Private Sub StartButton_Click()
Money = 100
End Sub

Then, in the UserForm code:

Dim StoreMoney as Double

'--I have macros that set the value of StoreMoney

Private Sub BuyStuff_Click()
If Money = StoreMoney Then
Money = Money - StoreMoney
Sheet1.Range("E9") = Money
Else: OK = MsgBox("You don't have enough money!", vbOKOnly, "Not
enough cash!")
End If
End Sub


The problem is that the userform does not know that Money=100, so it
just set's it at zero. How can I tell the userform code to use the
variable from the worksheet code?

Thanks,
Chris
 
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
Problems with userform, refercencing code to worksheet Zigball Excel Programming 2 October 25th 06 04:52 PM
how to prevent code running when in a worksheet code Corey Excel Programming 5 August 13th 06 08:52 AM
Code in userform/worksheet vs. in Module davegb Excel Programming 2 June 19th 06 04:17 PM
Code Conflicts With Worksheet Change Code Paige Excel Programming 3 March 3rd 06 04:25 PM
Create a newworksheet with VBA code and put VBA code in the new worksheet module ceshelman Excel Programming 4 June 15th 05 04:37 PM


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