View Single Post
  #14   Report Post  
Posted to microsoft.public.excel,microsoft.public.excel.misc,microsoft.public.excel.programming
teepee teepee is offline
external usenet poster
 
Posts: 103
Default Userform combobox question


"Dave Peterson" wrote in message
...
It worked for me.

Did you make any changes to the other code?

If you did, you may want to post that code.


Hmm the other code refers to command buttons. I put both in verbatim (just
changing the formula addresses) but then it won't let me launch the userform
at all but calls a bug at UserForm2.Show

In the userform

Private Sub UserForm_Initialize()
Dim myRng As Range

With ThisWorkbook.Worksheets("graphs")
Set myRng = .Range("fa1:fb" & .Cells(.Rows.Count,
"A").End(xlUp).Row)
End With
With Me.ComboBox1
.ColumnCount = myRng.Columns.Count
.List = myRng.Value
.ColumnWidths = "33;0"
End With

Me.CommandButton18.Caption = "Cancel"
Me.CommandButton19.Caption = "Ok"
End Sub

and

Option Explicit
Private Sub CommandButton18_Click()
Unload Me
End Sub
Private Sub CommandButton19_Click()
With Me.ComboBox1
If .ListIndex < 0 Then
Beep
Else
'pick out the second column
MsgBox .List(.ListIndex, 1)
End If
End With
End Sub

and in the combobox code

Private Sub Combobox1_change()



Dim myVar As Variant
With Me.ComboBox1
If .ListIndex < 2 Then
Beep
Else
'pick out the second column
myVar = .List(.ListIndex, 1)
MsgBox myVar



End If
End With

MP.CurrentPosition = myVar

End Sub