Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default Setting ComboBox ControlSource in code

Excel 2k

Morning!

I've trying to set the control Source for a combobox (On a
userform). I have:

Private Sub UserForm_Initialize()
Me.ComboBox1.ControlSource = Range("C1:C11").Value
End Sub

This isn't working (Type mismatch). Can anyone help?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 811
Default Setting ComboBox ControlSource in code

Hi Jim,

I think you've got the purpose of the ControlSource property
misconstrued (easy to do given it's ambiguous name). The ControlSource is
the address of a single cell on a worksheet where you want the value
selected in the ComboBox to be placed.

The RowSource property is the one you want to use to load a list from a
worksheet. The syntax for this property would look something like this:

Private Sub UserForm_Initialize()
ComboBox1.RowSource = "Sheet1!C1:C11"
End Sub

--
Rob Bovey, MCSE, MCSD, Excel MVP
Application Professionals
http://www.appspro.com/

* Please post all replies to this newsgroup *
* I delete all unsolicited e-mail responses *


"JimPNicholls" wrote in message
...
Excel 2k

Morning!

I've trying to set the control Source for a combobox (On a
userform). I have:

Private Sub UserForm_Initialize()
Me.ComboBox1.ControlSource = Range("C1:C11").Value
End Sub

This isn't working (Type mismatch). Can anyone help?



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Setting ComboBox ControlSource in code

Jim,

It is a string property so you should use Address not Value.

But, it can also only return a value to one cell, not many.

--

HTH

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

"JimPNicholls" wrote in message
...
Excel 2k

Morning!

I've trying to set the control Source for a combobox (On a
userform). I have:

Private Sub UserForm_Initialize()
Me.ComboBox1.ControlSource = Range("C1:C11").Value
End Sub

This isn't working (Type mismatch). Can anyone help?



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default Setting ComboBox ControlSource in code

Rob

Thanks for your promt response. Works a treat!




-----Original Message-----
Excel 2k

Morning!

I've trying to set the control Source for a combobox (On

a
userform). I have:

Private Sub UserForm_Initialize()
Me.ComboBox1.ControlSource = Range("C1:C11").Value
End Sub

This isn't working (Type mismatch). Can anyone help?
.

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 296
Default Setting ComboBox ControlSource in code

On Mon, 23 Aug 2004 01:58:08 -0700, "JimPNicholls"
wrote:

Excel 2k

Morning!

I've trying to set the control Source for a combobox (On a
userform). I have:

Private Sub UserForm_Initialize()
Me.ComboBox1.ControlSource = Range("C1:C11").Value
End Sub

This isn't working (Type mismatch). Can anyone help?



From memory, isn't the control source a string?
In addition isn't the control source a reference to a single cell
In which case I guess the correct syntax is

Me.ComboBox1.ControlSource = Range("C1").Address

Since you're specifying C1:C11 are you sure you're not looking for the
Row Source property for the combobox?

in which case the syntax would be:

Me.ComboBox1.RowSource = Range("C1:C11").Address

Rgds
__
Richard Buttrey
Grappenhall, Cheshire, UK
__________________________
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
combobox code [email protected] uk Excel Discussion (Misc queries) 2 December 19th 09 08:37 AM
ComboBox Code John Calder New Users to Excel 4 July 28th 09 01:17 AM
question about the ControlSource of a ComboBox delaney_55 Excel Programming 2 April 18th 04 03:56 PM
Combobox setting Pat Excel Programming 4 April 14th 04 09:48 PM
Setting ComboBox Value Ripan[_5_] Excel Programming 0 March 3rd 04 10:52 PM


All times are GMT +1. The time now is 07:11 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"