Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 586
Default Load Values from a Range into a List Box

I have a workheet that contains a list on several companies in Col. A. When
my Userform is initialized it finds the lastrow in Col. A and then sets the
CompanyData Range. I am getting an error indicated below. I know I am doing
it wrong, but I don't know the best way to add the range to the list.

Private Sub UserForm_Initialize()

Dim CompanyData As Range
Dim LastRow As Long

'finds last row in company Column
LastRow = Sheets("Sheet2").Cells(Rows.Count, 1).End(xlUp).Row

'company list range
Set CompanyData = Sheets("Sheet2").Range("A1:A" & LastRow)

'loads company data range into Company ComboBox
ERROR = Me.cboCompany.ControlSource = "CompanyData"

End Sub

--
Cheers,
Ryan
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Load Values from a Range into a List Box

I'd use:

Me.cboCompany.list = CompanyData.value
or
Me.cboCompany.Rowsource = CompanyData.address(external:=true)

The .controlsource is like the linkedcell--not where the list should be picked
up from.


RyanH wrote:

I have a workheet that contains a list on several companies in Col. A. When
my Userform is initialized it finds the lastrow in Col. A and then sets the
CompanyData Range. I am getting an error indicated below. I know I am doing
it wrong, but I don't know the best way to add the range to the list.

Private Sub UserForm_Initialize()

Dim CompanyData As Range
Dim LastRow As Long

'finds last row in company Column
LastRow = Sheets("Sheet2").Cells(Rows.Count, 1).End(xlUp).Row

'company list range
Set CompanyData = Sheets("Sheet2").Range("A1:A" & LastRow)

'loads company data range into Company ComboBox
ERROR = Me.cboCompany.ControlSource = "CompanyData"

End Sub

--
Cheers,
Ryan


--

Dave Peterson
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
load list data Souris Excel Programming 1 January 8th 08 02:04 PM
Dropdown List from values in a Cell Range DrKacso Excel Programming 2 August 8th 06 11:15 PM
need to save values from a range of cells based on selection from list vhrao Excel Programming 1 July 19th 06 02:49 AM
How do I generate a list from a range of values robo7084 Excel Worksheet Functions 2 July 6th 06 01:48 AM
problem with Paste-Special-Values from a List (range of cells) crimsonkng Excel Programming 1 June 1st 05 09:51 PM


All times are GMT +1. The time now is 10:00 AM.

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

About Us

"It's about Microsoft Excel"