LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35
Default problem assigning range returned by function, to combobox rowsource

Hi, I have modified Dave Peterson's lovely 'mvlookup' function for
returning multiple objects from a lookup function, to instead return a
range rather than a concatenated string. I renamed it 'rvlookup'.

I initially encountered an object error as I attempted to set the
function's return value to a range rather than a string. After adding
a 'set' in front of the final return value statement, no more error there.

However, when I invoke the function code to set a rowsource property
of a combobox TO this range, I get the 'type mismatch error 13" message.

Rvlookup has inputs of a lookup value, the array in which to look, and
which column contains the values to be returned. These are the
essential code snippets:

Public Function rvlookup(lookupValue As Variant, tableArray As Range,
colIndexNum As Long) As Range
Dim myRes() As Variant
Dim i As Long

.....(code that sets myres(i) to all the matching values in the lookup
range. The code below then places those value into cells in a worksheet.)

'select Lookups worksheet
Sheets("lookups").Select
'select starting cell to paste mill codes
Range("l2").Select
For i = LBound(myRes) To UBound(myRes)
ActiveCell.Value = myRes(i)
ActiveCell.Offset(1, 0).Select
Next i

Set rvlookup = ActiveSheet.Range("l2:l" & (i - 1))
End Function

The above function is invoked when a value is chosen from a combobox
(cboCompany), and the rowsource of a second combobox (cboMills) is
being set to the range that is returned by rvlookup:

Sub cboCompany_Change()
frmMills.cboMills.RowSource = _
rvlookup(Worksheets("data").Range("c3"), _
Worksheets("Lookups").Range("C2:J139"), 2).Value

frmMills.cboMills.ControlSource = Worksheets("data").Range("d1")
frmMills.Show
End Sub

I get the type mismatch error when attempting to set the rowsource of
the cboMills combobox. Apparently it doesn't recognize that this is a
range? I added the '.value' at the end of the rowsource setting but
that didn't help.

Any ideas? Thanks to all,

Kate
 
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
RowSource for Sheet ComboBox Minitman Excel Worksheet Functions 3 March 24th 08 09:43 PM
Create a RowSource Depending on ComboBox Choice Blobbies Excel Discussion (Misc queries) 3 November 18th 07 01:22 AM
How Do I Load A ComboBox RowSource From The Results Of Another ComboBox Minitman[_4_] Excel Programming 3 October 26th 04 07:58 PM
combobox rowsource Newbie Excel Programming 1 September 8th 04 12:21 PM
ComboBox RowSource --- can I use a userform OWC10 spreadsheet range? Dean Frazier Excel Programming 0 February 11th 04 07:16 PM


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