galpinm
Dec 1st, 1999, 05:07 PM
I am having problems developing an application in VBA for Excel 97. I have a macro I call when a user clicks on a command button on the worksheet, but I cannot get it to pass on values to the macro. I'm trying to do it something like this:
Private Sub commandbutton1_click()
Dim a As Integer
Dim b as Integer
If optionbutton1.value = True Then
a=1, b=0
End If
If optionbutton2.value = True Then
a=0,b=1
End If
Call MainMacro(ByVal a,ByVal b)
End Sub
Public Sub Mainmacro(x as Integer, y as Integer)
etc
No matter whether I use Call Mainmacro(1,0) or whatever I can't seem to get the variables x and y to hold onto their values in the Mainmacro. They either come through undefined or both as zero, and so my macro won't work. I'm using the two variables because an option button on the form means the macro has to be called in one of two ways - & they're so similiar it's a waste of space to name two different macros. What am I doing wrong?
Private Sub commandbutton1_click()
Dim a As Integer
Dim b as Integer
If optionbutton1.value = True Then
a=1, b=0
End If
If optionbutton2.value = True Then
a=0,b=1
End If
Call MainMacro(ByVal a,ByVal b)
End Sub
Public Sub Mainmacro(x as Integer, y as Integer)
etc
No matter whether I use Call Mainmacro(1,0) or whatever I can't seem to get the variables x and y to hold onto their values in the Mainmacro. They either come through undefined or both as zero, and so my macro won't work. I'm using the two variables because an option button on the form means the macro has to be called in one of two ways - & they're so similiar it's a waste of space to name two different macros. What am I doing wrong?