View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Richard Buttrey Richard Buttrey is offline
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
__________________________