Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel,microsoft.public.excel.misc,microsoft.public.excel.programming
|
|||
|
|||
Userform button setting variable from formula
I have a userform that contains windows media player. I want to set
CommandButton4 to take the value of the formula in cell A2 of the active sheet and set it as the value of variable named 'inset'. I'm finding the VBA code on this much harder to write than I thought it would be. Any ideas please, anyone? |
#2
Posted to microsoft.public.excel,microsoft.public.excel.misc,microsoft.public.excel.programming
|
|||
|
|||
Userform button setting variable from formula
"ShaunM" wrote I am a bit confused by your request but I think that it as simple as: Private Sub CommandButton4_Click() inset = Range("A2").Value MsgBox ("The value of cell A2 is: " & inset) End Sub Thanks Shaun, that's kind of you to respond. I think the problem with your suggestion might be that the variable is only then available within the userform itself whereas I need to refer to the variable within other macros. Do I not need another approach if the variable is to be generally available elsewhere in the spreadsheet? |
#3
Posted to microsoft.public.excel,microsoft.public.excel.misc,microsoft.public.excel.programming
|
|||
|
|||
Userform button setting variable from formula
"BizMark" wrote All you need to do is use the example above, except you need to add a Module to the project and declare the variable as public, like so: Public inset As Integer Worked a treat. Many thanks to you both tp |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Userform button setting variable from formula | Excel Discussion (Misc queries) | |||
Userform button setting variable from formula | Excel Discussion (Misc queries) | |||
Directly setting variable to formula | Excel Programming | |||
setting a range variable equal to the value of a string variable | Excel Programming |