LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,069
Default Create array

If they are really merged cells, all the data is in the first (topmost left)
cell. If the data is separated by some delimiting character, you can load the
combobox with a routine similar to this:

Private Sub UserForm_Initialize()
Dim DelimRng As Range
Dim x As Long, zzz
'identify the delimiting character
Const DelimChar = ","
'only need the first (topmost left) cell of the merged range
Set DelimRng = Sheets("Sheet1").Range("Q1")
'use SPLIT to populate an array variable
zzz = Split(DelimRng.Value, DelimChar)
'add the array items to the combobox
For x = LBound(zzz) To UBound(zzz)
Me.ComboBox1.AddItem Trim(zzz(x))
Next x
Set DelimRng = Nothing
End Sub

If you mean that your Q1:MN1 range includes several sets of merged cells,
you can load the combobox by looping through the whole range. Merged cells
are treated as a single cell. For example:

Private Sub UserForm_Initialize()
Dim SelRng As Range, c As Range
Const DelimChar = ","
Set SelRng = Sheets("Sheet1").Range("Q1:Z10")
For Each c In SelRng
If Len(Trim(c.Value)) 0 Then
Me.ComboBox1.AddItem Trim(c.Value)
End If
Next c
Set SelRng = Nothing
End Sub

Hope this helps,

Hutch

"QB" wrote:

I have a row in which I have an undefined number of merged cells (Varying in
the number of cells that each merged cell is comprised of). I now need to
populate a userform combobox with the values.

I tried doing

Me.combobox1.RowSource = "Sheet1!Q1:MN1"

but the cbo only has the first value appear. How can I get the full list of
the merged cell values into the cbo?

Thank you

QB

 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to Create an array JB[_5_] Excel Programming 7 February 2nd 08 03:33 PM
create array Al[_19_] Excel Programming 6 July 13th 07 08:29 PM
how do I create an array lost Excel Discussion (Misc queries) 6 April 7th 05 12:43 AM
how do I create an array array_deficient Excel Discussion (Misc queries) 0 April 6th 05 09:53 PM
Create array function Yuriy Kuznetsov Excel Programming 2 November 2nd 04 03:05 PM


All times are GMT +1. The time now is 08:28 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"