View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
freddy freddy is offline
external usenet poster
 
Posts: 87
Default Using Checkboxes

I wrote sample code as per your example, however, after Sub Customer1() is
done how do I direct the code back to check the value of the next checkbox
and so on? Here is an outline of what I've done so far:

Private Sub UserForm_Initialize()

CheckBox1.Caption = "Customer1"
CheckBox2.Caption = "Customer2"
CheckBox3.Caption = "Customer3"

End Sub

Private Sub CommandButton1_Click()

If CheckBox1.Value = True Then Call SubCustomer1
If CheckBox2.Value = True Then Call SubCustomer2
If CheckBox3.Value = True Then Call SubCustomer3

End Sub

Sub Customer1()
My code€¦
End Sub

Sub Customer2()
My code€¦
End Sub

Sub Customer3()
My code€¦
End Sub


"John Bundy" wrote:

There are various ways, the easiest is probably to insert a new module and
place your code there, such as
Sub Customer1()
MsgBox "Customer Selected"
End Sub

then in the code on the sheet you can call that sub
Call Customer1

then messagebox will appear.
Now just check to see if each is selected and call the appropriate sub routine
--
-John Northwest11
Please rate when your question is answered to help us and others know what
is helpful.


"Freddy" wrote:

I'd like to create a userform containing multiple checkboxes that, after the
user enables the ones selected, will run a corresponding VB macro. For
example, I'd like to create a checklist of customer names, the user selects
the ones to be processed, then the user would click a "Go" button, then all
of the selected customer names would invoke a corresponding but different VB
macro. (Customer1 would run macro1, Customer2 would run macro2... not macro1,
etc.) Does anyone have sample code I can refer to?