Newbie Question - Excel VBA
The click event of the command button does not accept arguments because it
is not normally called from another routine. If you want to establish some
condition that the button's code will react to, you might declare a public
variable (or more than one) at the top of the general module (not a sheet,
workbook or userform module) outside any procedure.
Public myvar as long
then set the value for this variable from your routine. The click event can
have code that looks at this variable
Private Sub commandbutton1_Click()
if myvar = 3 then
msgbox "Myvar is 3"
else
msgbox "Myvar is not 3"
end if
End Sub
--
Regards,
Tom Ogilvy
"Hambone" wrote in message
om...
Have written some elementary VBA code in an excel spreadsheet with a
UserForm that shows on demand with some calculated output using some
of spreadsheets cells as input.
Please excuse my terminology, I am embarrased enough to try to even
ask.
The problem is, that I have a command button on the UserForm. I cannot
seem to get the variables in the main "sheet1" or Worksheet(?) code to
pass to the command button code for the UserForm (click event).
How can I call them up to the UserForm CommandButton code please ?
If this makes sense to anybody I'd appreciate a response.
|