View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Mike Mike is offline
external usenet poster
 
Posts: 3,101
Default Best way to solicit input then run a macro?

'Sub showForm() 'Put this into a standard module
'UserForm1.Show
'End Sub
'Put this into Thisworkbook module
'Private Sub Workbook_Open()
'Run "showForm"
'End Sub

'Add two comboboxes and a button to
'userform1
Private Sub CommandButton1_Click()
'Do your stuff
MsgBox ComboBox1.Text & " " & ComboBox2.Text
End Sub

Private Sub UserForm_Initialize()
Const combobox1ListColumn = "A" 'Change to your needs
Const combobox2ListColumn = "B" 'Change to your needs
Dim cellPointer As Variant


lastRow = Range(combobox1ListColumn & Rows.Count).End(xlUp).Row
looper = 1 'Starting row of data to fill combox1
ComboBox1.Text = Range(combobox1ListColumn & looper)
Do While looper <= lastRow
Set cellPointer = Range(combobox1ListColumn & looper)
ComboBox1.AddItem (cellPointer)
looper = looper + 1
Loop
'reset lastrow & looper
lastRow = Range(combobox2ListColumn & Rows.Count).End(xlUp).Row
looper = 1 'Starting row of data to fill combox2
ComboBox2.Text = Range(combobox2ListColumn & looper)
Do While looper <= lastRow
Set cellPointer = Range(combobox2ListColumn & looper)
ComboBox2.AddItem (cellPointer)
looper = looper + 1
Loop
End Sub

"fedude" wrote:

I have to solicit two pieces of information (both pieces will be selections
from a small list) and then run a macro. I'd prefer to make this obvious
instead of doing the crtl-key to run the macro, because an inexperienced user
will be running it.

What is the best way to do this? Should I create a form? Can I customize
the form (colors? pictures? buttons?). Other ways?