Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 15
Default Populating ComboBoxes

I'm trying to populate a combobox control with items from a Range on a
worksheet. I have code that returns a Variant assigned to a Range of cells
in a WorkSheet. Is there an easy way to assign these values to the ComboBox,
or must I loop through the Variant array? I tried assigning the ComboBox
RowSource Property to the Variant but got an error. My code looks something
like this:

Public Function GetData() as Variant
Dim rng as Range
Set rng = MyWorkSheet.Range("$A$1:$E$1")
GetData = rng
End Function

Private Sub MyForm_Initialize()
ComboBox1.RowSource = GetData
End Sub


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Populating ComboBoxes

William,

The Rowsource property is a string, so either return a string in the
function (rng.Address), or do it the form initialise (ComboBox1.RowSource =
GetData.Address )

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"WIlliam Barnes" wrote in message
...
I'm trying to populate a combobox control with items from a Range on a
worksheet. I have code that returns a Variant assigned to a Range of cells
in a WorkSheet. Is there an easy way to assign these values to the

ComboBox,
or must I loop through the Variant array? I tried assigning the ComboBox
RowSource Property to the Variant but got an error. My code looks

something
like this:

Public Function GetData() as Variant
Dim rng as Range
Set rng = MyWorkSheet.Range("$A$1:$E$1")
GetData = rng
End Function

Private Sub MyForm_Initialize()
ComboBox1.RowSource = GetData
End Sub




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 15
Default Populating ComboBoxes

Thanks Bob. That's what it took.

"Bob Phillips" wrote in message
...
William,

The Rowsource property is a string, so either return a string in the
function (rng.Address), or do it the form initialise (ComboBox1.RowSource

=
GetData.Address )

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"WIlliam Barnes" wrote in message
...
I'm trying to populate a combobox control with items from a Range on a
worksheet. I have code that returns a Variant assigned to a Range of

cells
in a WorkSheet. Is there an easy way to assign these values to the

ComboBox,
or must I loop through the Variant array? I tried assigning the ComboBox
RowSource Property to the Variant but got an error. My code looks

something
like this:

Public Function GetData() as Variant
Dim rng as Range
Set rng = MyWorkSheet.Range("$A$1:$E$1")
GetData = rng
End Function

Private Sub MyForm_Initialize()
ComboBox1.RowSource = GetData
End Sub






Reply
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
comboboxes [email protected] uk Excel Discussion (Misc queries) 1 December 6th 09 05:07 PM
Comboboxes mr-bear New Users to Excel 1 November 21st 06 10:05 AM
Urgent Help, Comboboxes and IF. R.Chapman Excel Discussion (Misc queries) 1 February 16th 06 07:50 PM
Need help with ComboBoxes. rosemary New Users to Excel 2 July 9th 05 12:19 AM
Comboboxes David W[_3_] Excel Programming 1 August 29th 03 11:13 PM


All times are GMT +1. The time now is 05:27 AM.

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

About Us

"It's about Microsoft Excel"