PC Review


Reply
Thread Tools Rate Thread

ComboBox Rowsource question

 
 
Patrick C. Simonds
Guest
Posts: n/a
 
      11th Jul 2009
I have a UserForm with a ComboBox. The current RowSource for the ComboBox is
shown below. Is it possible to make the RowSource be the range $P$2:$P$300
of the active worksheet? I have 12 different worksheets that can call this
one UserForm.

'Names'!$P$2:$P$300

 
Reply With Quote
 
 
 
 
Nigel
Guest
Posts: n/a
 
      11th Jul 2009
Define/re-define the row source with

ComboBox1.RowSource = ActiveSheet.Name & "!$P$1:$P$300"

When you do this needs to be controlled, maybe the worksheet activate event?

--

Regards,
Nigel
(E-Mail Removed)



"Patrick C. Simonds" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
>I have a UserForm with a ComboBox. The current RowSource for the ComboBox
>is shown below. Is it possible to make the RowSource be the range
>$P$2:$P$300 of the active worksheet? I have 12 different worksheets that
>can call this one UserForm.
>
> 'Names'!$P$2:$P$300


 
Reply With Quote
 
Nigel
Guest
Posts: n/a
 
      11th Jul 2009
Just noticed you say the UserForm is called from one of 12 sheets, therefore
put this in the UserForm initialize event.


Private Sub UserForm_Initialize()
ComboBox1.RowSource = ActiveSheet.Name & "!$P$2:$P$300"
End Sub


--

Regards,
Nigel
(E-Mail Removed)



"Nigel" <(E-Mail Removed)> wrote in message
news:O4U$(E-Mail Removed)...
> Define/re-define the row source with
>
> ComboBox1.RowSource = ActiveSheet.Name & "!$P$1:$P$300"
>
> When you do this needs to be controlled, maybe the worksheet activate
> event?
>
> --
>
> Regards,
> Nigel
> (E-Mail Removed)
>
>
>
> "Patrick C. Simonds" <(E-Mail Removed)> wrote in message
> news:%(E-Mail Removed)...
>>I have a UserForm with a ComboBox. The current RowSource for the ComboBox
>>is shown below. Is it possible to make the RowSource be the range
>>$P$2:$P$300 of the active worksheet? I have 12 different worksheets that
>>can call this one UserForm.
>>
>> 'Names'!$P$2:$P$300

>


 
Reply With Quote
 
Patrick C. Simonds
Guest
Posts: n/a
 
      11th Jul 2009
I tried this a few different ways, no of which worked:

Private Sub Worksheet_Activate()
ComboBox1.RowSource = ActiveSheet.Name & "!$P$1:$P$300"

End Sub

Private Sub Worksheet_Activate()
With UserForm2
ComboBox1.RowSource = ActiveSheet.Name & "!$P$1:$P$300"
End With
End Sub

Both of which returned an "Object Required error"

And then within the UserForm Initialization, but it returned "Could not set
the RowSource property. Invalid property value"

"Nigel" <(E-Mail Removed)> wrote in message
news:O4U$(E-Mail Removed)...
> Define/re-define the row source with
>
> ComboBox1.RowSource = ActiveSheet.Name & "!$P$1:$P$300"
>
> When you do this needs to be controlled, maybe the worksheet activate
> event?
>
> --
>
> Regards,
> Nigel
> (E-Mail Removed)
>
>
>
> "Patrick C. Simonds" <(E-Mail Removed)> wrote in message
> news:%(E-Mail Removed)...
>>I have a UserForm with a ComboBox. The current RowSource for the ComboBox
>>is shown below. Is it possible to make the RowSource be the range
>>$P$2:$P$300 of the active worksheet? I have 12 different worksheets that
>>can call this one UserForm.
>>
>> 'Names'!$P$2:$P$300

>

 
Reply With Quote
 
Patrick C. Simonds
Guest
Posts: n/a
 
      11th Jul 2009
Thanks

With your help I was able to use what you gave me and I was better able to
refine my internet search. It seems that if you put no worksheet reference,
it defaults to the active worksheet.

ComboBox1.RowSource = "$P$7:$P$3000"

"Patrick C. Simonds" <(E-Mail Removed)> wrote in message
news:#(E-Mail Removed)...
> I tried this a few different ways, no of which worked:
>
> Private Sub Worksheet_Activate()
> ComboBox1.RowSource = ActiveSheet.Name & "!$P$1:$P$300"
>
> End Sub
>
> Private Sub Worksheet_Activate()
> With UserForm2
> ComboBox1.RowSource = ActiveSheet.Name & "!$P$1:$P$300"
> End With
> End Sub
>
> Both of which returned an "Object Required error"
>
> And then within the UserForm Initialization, but it returned "Could not
> set the RowSource property. Invalid property value"
>
> "Nigel" <(E-Mail Removed)> wrote in message
> news:O4U$(E-Mail Removed)...
>> Define/re-define the row source with
>>
>> ComboBox1.RowSource = ActiveSheet.Name & "!$P$1:$P$300"
>>
>> When you do this needs to be controlled, maybe the worksheet activate
>> event?
>>
>> --
>>
>> Regards,
>> Nigel
>> (E-Mail Removed)
>>
>>
>>
>> "Patrick C. Simonds" <(E-Mail Removed)> wrote in message
>> news:%(E-Mail Removed)...
>>>I have a UserForm with a ComboBox. The current RowSource for the ComboBox
>>>is shown below. Is it possible to make the RowSource be the range
>>>$P$2:$P$300 of the active worksheet? I have 12 different worksheets that
>>>can call this one UserForm.
>>>
>>> 'Names'!$P$2:$P$300

>>

 
Reply With Quote
 
Nigel
Guest
Posts: n/a
 
      11th Jul 2009
If your active sheet name has spaces then you need to enclose the name in
single quotes, but as your later post shows leaving it blank will act on the
active sheet anyway. Always assuming the active sheet is a worksheet.


--

Regards,
Nigel
(E-Mail Removed)



"Patrick C. Simonds" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
>I tried this a few different ways, no of which worked:
>
> Private Sub Worksheet_Activate()
> ComboBox1.RowSource = ActiveSheet.Name & "!$P$1:$P$300"
>
> End Sub
>
> Private Sub Worksheet_Activate()
> With UserForm2
> ComboBox1.RowSource = ActiveSheet.Name & "!$P$1:$P$300"
> End With
> End Sub
>
> Both of which returned an "Object Required error"
>
> And then within the UserForm Initialization, but it returned "Could not
> set the RowSource property. Invalid property value"
>
> "Nigel" <(E-Mail Removed)> wrote in message
> news:O4U$(E-Mail Removed)...
>> Define/re-define the row source with
>>
>> ComboBox1.RowSource = ActiveSheet.Name & "!$P$1:$P$300"
>>
>> When you do this needs to be controlled, maybe the worksheet activate
>> event?
>>
>> --
>>
>> Regards,
>> Nigel
>> (E-Mail Removed)
>>
>>
>>
>> "Patrick C. Simonds" <(E-Mail Removed)> wrote in message
>> news:%(E-Mail Removed)...
>>>I have a UserForm with a ComboBox. The current RowSource for the ComboBox
>>>is shown below. Is it possible to make the RowSource be the range
>>>$P$2:$P$300 of the active worksheet? I have 12 different worksheets that
>>>can call this one UserForm.
>>>
>>> 'Names'!$P$2:$P$300

>>


 
Reply With Quote
 
Dave Peterson
Guest
Posts: n/a
 
      11th Jul 2009
I like to let excel do the heavy lifting...

Dim myRng as range
set myrng = activesheet.range("p2300")
....

... = myrng.address(external:=true)

------------
If you want to supply the string yourself:
... = "'" & activesheet.name & "'!p2300"

(Some names will require those apostrophes.)

"Patrick C. Simonds" wrote:
>
> I have a UserForm with a ComboBox. The current RowSource for the ComboBox is
> shown below. Is it possible to make the RowSource be the range $P$2:$P$300
> of the active worksheet? I have 12 different worksheets that can call this
> one UserForm.
>
> 'Names'!$P$2:$P$300


--

Dave Peterson
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
ComboBox RowSource Question =?Utf-8?B?TWlrZSBTYW15bg==?= Microsoft Excel Programming 3 10th Aug 2006 11:04 PM
combobox rowsource J Holtendehouzer Microsoft Access Queries 1 6th Apr 2006 05:04 AM
UserForm ComboBox RowSource Question Minitman Microsoft Excel Programming 0 15th Nov 2005 07:03 PM
Combobox rowsource based on value of other combobox =?Utf-8?B?UmljaCBK?= Microsoft Access Form Coding 0 9th Nov 2004 10:15 PM
How Do I Load A ComboBox RowSource From The Results Of Another ComboBox Minitman Microsoft Excel Programming 3 26th Oct 2004 07:58 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:49 AM.