2-Column ComboBox Issues

J

Justin

Hey all,

I current have a ComboBox on a UserForm with 2 columns. The first
column displays formatted values, and the second invisible column
contains key unformatted numbers from the same list that are bound to
the spreadsheet and change the spreadsheet cell when an item on the
list changes.

I am using this code below to populate my column lists:

With UserForm1.MultiPage1.Pages(0).MultiPage2.Pages(1).ComboBox1
.ColumnCount = 2
.BoundColumn = 2
.ColumnWidths = "-1;0"

For j = 12 To 23
.AddItem
Format((Worksheets("Worksheet1").Cells(j, 11).Value), "#0.000")
.List(.ListCount - 1, 1) =
Worksheets("Worksheet1").Cells(j, 11).Value
Next j
End With

MY PROBLEM: Right now - it is erasing data in the spreadsheet cell, and
I don't know how to populate the ComboBox Column 1 with what was last
selected in the ComboBox list. Right now it's blank... Any suggestions
on how to implement a solution into the code I'm using above?

Thanks!!!
 
T

Tom Ogilvy

With UserForm1.MultiPage1.Pages(0).MultiPage2.Pages(1).ComboBox1
v = .Value
.ColumnCount = 2
.BoundColumn = 2
.ColumnWidths = "-1;0"

For j = 12 To 23
.AddItem
Format((Worksheets("Worksheet1").Cells(j, 11).Value), "#0.000")
.List(.ListCount - 1, 1) =
Worksheets("Worksheet1").Cells(j, 11).Value
Next j
.Value = v
End With
 
J

Justin

Thanks Tom! I just tried that and it's still blank and clearing out the
cell in the spreadsheet. Maybe I am defining the wrong column?
 
T

Tom Ogilvy

I was a guess. There is nothing in the code shown that writes to the
worksheet.

I figured you might have it linked to a cell and when you rebuilt the list,
it cleared the selection and cleared the cell (and or triggers the change
event)
 

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

Top