ComboBox RowSource assignment by procedure code?

TTom

Well-known Member
Joined
Jan 19, 2005
Messages
518
ComboBox RowSource assignment by procedure code:

In a module sub I want to have code that assigns the RowSource value to a named ranged prior to
showing the UserForm that contains the ComboBox where the RowSource is to be filled.
(This will fill the ComboBox with named range data.)

The following code gets an error as invalid. Is RowSource assignment by code not allowed for Comobox, or do I just need to tweak my code?

Thanks for any tips. TTom
<code>
ActiveWorkbook.Names.Add Name:="nrng_Jobs", RefersTo:="=Sheet2!$T$1:$T$" & Range("T6000").End(xlUp).Row

ufJobSelect.cbxJobSelect.RowSource = "nrng_Jobs"
</code>
 

Excel Facts

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop

TTom

Well-known Member
Joined
Jan 19, 2005
Messages
518
Even if I type in the named range, or even just a 'single cell range' into the ComboBox's RowSource
property setting I get an 'Invalid Property Value" error. Hmmm.... :rolleyes:
TTom
 

Norie

Well-known Member
Joined
Apr 28, 2004
Messages
76,344
Office Version
  1. 365
Platform
  1. Windows
Are you sure the range is being defined correctly?
Code:
With Worksheets("Sheet2")
    LastRow = .Range("T" & Rows.Count).End(xlUp).Row
    .Range("T1:T" & LastRow).Name = "nrng_Jobs"
End With
 

TTom

Well-known Member
Joined
Jan 19, 2005
Messages
518
Norie,
This resolved my problem :)
I'll have to study my named range assignments! :wink:
Thanks, TTom
 

Norie

Well-known Member
Joined
Apr 28, 2004
Messages
76,344
Office Version
  1. 365
Platform
  1. Windows
I don't actually think it was anything to do with that.

I think the problem was the unqualified reference to Range("T6000").

Could be wrong though.:)
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,164,292
Messages
5,836,451
Members
430,431
Latest member
Tomexcel2022

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top