Question for dave Paterson

C

capt

Sorry dave to get back to you on an old question.
I have the following code you sent us last week.

Private Sub ComboBox1_Change()
With Me.ComboBox1
If .ListIndex < 0 Then
Me.TextBox3.Value = ""
Else
Me.TextBox3.Value = .List(.ListIndex, 1)
End If
End With
End Sub

Private Sub UserForm_Initialize()
With Me.ComboBox1
.RowSource =
Worksheets("list").Range("A1:B18").Address(external:=False)
.ColumnCount = 2
.BoundColumn = 1
.ColumnWidths = "22;0" 'hide the second column
End With
End Sub

The problem I am having now is when I select the combobox the list does not
appear yet I checked all the links but I cant find what is wrong.
What am I doing wrong!!!!???
 
D

Dave Peterson

You sure you have something in A1:B18 of the List worksheet--especially the
column A?
 
C

capt

I have just managed to get the combobox to work, it now shows the list!
But running the code I get the Debug warning with the following line high
lighted in yellow:

Me.TextBox3.Value = .List(.ListIndex, 1)

Any ideas Dave?
--
capt


capt said:
Thanks for getting back to me.
Yes I have data down columns A and B
 
D

Dave Peterson

None at all.

Are you going to share your code and the actual error message that shows up?

And what did you do to get the combobox to work? I'm curious why it didn't work
before.
 
C

capt

Abit embarassing!! I never indicated what userform it was. In this case "4"

Private Sub UserForm4_Initialize()
With Me.ComboBox1
.RowSource =
Worksheets("list").Range("A1:B18").Address(external:=False)
.ColumnCount = 2
.BoundColumn = 1
.ColumnWidths = "22;0" 'hide the second column
End With
End Sub

I get a debug warning on the following code when run:
Private Sub ComboBox1_Change()
With Me.ComboBox1
If .ListIndex < 0 Then
Me.TextBox3.Value = ""
Else
Me.TextBox3.Value = .List(.ListIndex, 1)
End If
End With
End Sub

The following line gets high lighted in yellow:

Me.TextBox3.Value = .List(.ListIndex, 1)
 
D

Dave Peterson

That's not it.

"UserForm_Initialize" is the name of the procedure that excel looks for when the
userform is shown/loaded. You can't change that name.

It's just like the worksheet/workbook/application event names. You can't change
these, either.

But I don't have a guess why the code doesn't work for you.
Abit embarassing!! I never indicated what userform it was. In this case "4"

Private Sub UserForm4_Initialize()
With Me.ComboBox1
.RowSource =
Worksheets("list").Range("A1:B18").Address(external:=False)
.ColumnCount = 2
.BoundColumn = 1
.ColumnWidths = "22;0" 'hide the second column
End With
End Sub

I get a debug warning on the following code when run:
Private Sub ComboBox1_Change()
With Me.ComboBox1
If .ListIndex < 0 Then
Me.TextBox3.Value = ""
Else
Me.TextBox3.Value = .List(.ListIndex, 1)
End If
End With
End Sub

The following line gets high lighted in yellow:

Me.TextBox3.Value = .List(.ListIndex, 1)
 
C

capt

Got it......sorted now.

I checked Combobox1 properties, RowSourse:

It was reading: =list!a1:a18

it should be: =list!a1:b18

typing error.

Thanks
 
D

Dave Peterson

The userform4_initial procedure isn't being used.

You could remove the value from the .rowsource property and use the original
code to populate the .rowsource.


Got it......sorted now.

I checked Combobox1 properties, RowSourse:

It was reading: =list!a1:a18

it should be: =list!a1:b18

typing error.

Thanks

--
capt

Dave Peterson said:
That's not it.

"UserForm_Initialize" is the name of the procedure that excel looks for when the
userform is shown/loaded. You can't change that name.

It's just like the worksheet/workbook/application event names. You can't change
these, either.

But I don't have a guess why the code doesn't work for you.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top