ListBox Select every other cell

TKB

Board Regular
Joined
Aug 18, 2011
Messages
128
Hello,

I currently have the following code populating a list box i have:

ComboBox1.List = Application.Transpose(Sheets("Folders and Documents").Range("A1:D1").Value) 'Supplied to me from AlphaFrog!


The code im looking for will be used elsewhere, but i havent created the data yet so im using the above as a reference. What i need to do is have that same type of function, but only include every other cell in the list box.

So in the list, instead of showing A,B,C,D,E,F,G,H it would show A,C,E,G

Any ideas?

Thanks,

Trey
 

Excel Facts

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.
For 4 Items use sometink like...

Code:
Sub Foo()
For i = 0 To 3
   ActiveSheet.OLEObjects("Listbox1"). _
      Object.AddItem Cells(1, (i * 2) + 1).Value  'The Values in Cells A1, C1, E1, and G1
Next i
End Sub
 
Upvote 0
Jim, i made a mistake in my discription... It should have said ComboBox... Sorry.
 
Upvote 0
When trying that it says:

"Unable to get the OLEObjects property of the worksheet class"

I have no clue what that means... and ive never used.

And I dont think i ever defined that this is a combobox in a user form.

Thanks for your help on this Jim!
 
Upvote 0
Jim, i made a mistake in my discription... It should have said ComboBox... Sorry.

My code is for a Listbox directly on a worksheet, not on a User Form.
I'm in meeting now, so I am unable to look any further, for now.

Jim
 
Last edited:
Upvote 0

Forum statistics

Threads
1,203,051
Messages
6,053,220
Members
444,648
Latest member
sinkuan85

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top