A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Excel » General Discussion
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Userform combobox question



 
 
Thread Tools Display Modes
  #11  
Old May 13th, 2007, 10:06 PM posted to microsoft.public.excel,microsoft.public.excel.misc,microsoft.public.excel.programming
teepee[_2_]
external usenet poster
 
Posts: 48
Default Userform combobox question

myVar = .List(.ListIndex, 1)

is the offending line in the debugger
Office 2007


  #12  
Old May 13th, 2007, 11:04 PM posted to microsoft.public.excel,microsoft.public.excel.misc,microsoft.public.excel.programming
teepee[_2_]
external usenet poster
 
Posts: 48
Default Userform combobox question


"teepee" wrote in message
...
myVar = .List(.ListIndex, 1)

is the offending line in the debugger

and it also says 'can't get the list property. Invalid argument.' when I
hover the cursor over .list


  #13  
Old May 13th, 2007, 11:19 PM posted to microsoft.public.excel,microsoft.public.excel.misc,microsoft.public.excel.programming
Dave Peterson
external usenet poster
 
Posts: 19,791
Default Userform combobox question

It worked for me.

Did you make any changes to the other code?

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

teepee wrote:

"teepee" wrote in message
...
myVar = .List(.ListIndex, 1)

is the offending line in the debugger

and it also says 'can't get the list property. Invalid argument.' when I
hover the cursor over .list


--

Dave Peterson
  #14  
Old May 15th, 2007, 05:23 PM posted to microsoft.public.excel,microsoft.public.excel.misc,microsoft.public.excel.programming
teepee[_2_]
external usenet poster
 
Posts: 48
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







  #15  
Old May 15th, 2007, 06:05 PM posted to microsoft.public.excel,microsoft.public.excel.misc,microsoft.public.excel.programming
Dave Peterson
external usenet poster
 
Posts: 19,791
Default Userform combobox question

But I still have no idea what MP.CurrentPosition is. Until you share that, I'm
not sure how to help.

teepee wrote:

"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



--

Dave Peterson
  #16  
Old May 15th, 2007, 07:28 PM posted to microsoft.public.excel,microsoft.public.excel.misc,microsoft.public.excel.programming
teepee[_2_]
external usenet poster
 
Posts: 48
Default Userform combobox question


"Dave Peterson" wrote in message
...
But I still have no idea what MP.CurrentPosition is. Until you share that,
I'm
not sure how to help.

mp.currentposition won't have any impact on the rest of the code - I just
included it for completeness. The userform has an embedded media player and
mp.currentposition = 10 would tell it to jump to 10 seconds into a video or
audio.


  #17  
Old May 15th, 2007, 07:49 PM posted to microsoft.public.excel,microsoft.public.excel.misc,microsoft.public.excel.programming
Dave Peterson
external usenet poster
 
Posts: 19,791
Default Userform combobox question

It could be lots of things.

Can you be more specific about which line causes the error?

teepee wrote:

"Dave Peterson" wrote in message
...
But I still have no idea what MP.CurrentPosition is. Until you share that,
I'm
not sure how to help.

mp.currentposition won't have any impact on the rest of the code - I just
included it for completeness. The userform has an embedded media player and
mp.currentposition = 10 would tell it to jump to 10 seconds into a video or
audio.


--

Dave Peterson
  #18  
Old May 15th, 2007, 08:13 PM posted to microsoft.public.excel,microsoft.public.excel.misc,microsoft.public.excel.programming
teepee[_2_]
external usenet poster
 
Posts: 48
Default Userform combobox question

In this case it's where I invoke the userform itself

Sub startt()
UserForm2.Show
End Sub

I get

run time error 70
permission denied

but it does launch if I take out

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 replace it with

Private Sub UserForm_Initialize()

End Sub

"Dave Peterson" wrote in message
...
It could be lots of things.

Can you be more specific about which line causes the error?

teepee wrote:

"Dave Peterson" wrote in message
...
But I still have no idea what MP.CurrentPosition is. Until you share
that,
I'm
not sure how to help.

mp.currentposition won't have any impact on the rest of the code - I just
included it for completeness. The userform has an embedded media player
and
mp.currentposition = 10 would tell it to jump to 10 seconds into a video
or
audio.


--

Dave Peterson


  #19  
Old May 15th, 2007, 08:38 PM posted to microsoft.public.excel,microsoft.public.excel.misc,microsoft.public.excel.programming
teepee[_2_]
external usenet poster
 
Posts: 48
Default Userform combobox question

Further investigation shows that it is the presence of the line

..List = myRng.Value

that is causing the userform to not launch




  #20  
Old May 16th, 2007, 12:02 AM posted to microsoft.public.excel,microsoft.public.excel.misc,microsoft.public.excel.programming
Dave Peterson
external usenet poster
 
Posts: 19,791
Default Userform combobox question

Maybe you assigned the rowsource to the combobox.

You could either remove that assignment in the properties window for that
combobox (while you're in the VBE).

Or you could clean it up in code:

Add a single line right after the with statement:

With Me.ComboBox1
.RowSource = ""



teepee wrote:

In this case it's where I invoke the userform itself

Sub startt()
UserForm2.Show
End Sub

I get

run time error 70
permission denied

but it does launch if I take out

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 replace it with

Private Sub UserForm_Initialize()

End Sub

"Dave Peterson" wrote in message
...
It could be lots of things.

Can you be more specific about which line causes the error?

teepee wrote:

"Dave Peterson" wrote in message
...
But I still have no idea what MP.CurrentPosition is. Until you share
that,
I'm
not sure how to help.

mp.currentposition won't have any impact on the rest of the code - I just
included it for completeness. The userform has an embedded media player
and
mp.currentposition = 10 would tell it to jump to 10 seconds into a video
or
audio.


--

Dave Peterson


--

Dave Peterson
 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 09:03 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.