PC Review


Reply
Thread Tools Rate Thread

Define Range Dynamically

 
 
Randy
Guest
Posts: n/a
 
      17th Sep 2007
I know this one should be easy, but I can't make it work. I'm trying
to dynamically define a range and assign it to a combobox on a user
form as the rowsource. Here is my code:

dim rngGrpList as Range
Set rngGrpList = Sheet1.Range("Groups",
Sheet1.Range("Groups").Offset.End(xlDown))
frmManageGroups.cboGroups.RowSource = rngGrpList

I'm getting a type mismatch error. It seems that my second line is
capturing the contents of the cells rather than their addresses. I've
played around with different ideas, but nothing seems to work. Can
anybody see why this won't work as intended?

Thanks,
Randy

 
Reply With Quote
 
 
 
 
Tim Zych
Guest
Posts: n/a
 
      17th Sep 2007
Does this help?

Sheet1.Range(Sheet1.Range("Groups")(1, 1), _
Sheet1.Range("Groups")(1, 1).End(xlDown)).Name = "Groups"
frmManageGroups.cboGroups.RowSource = "Groups"



"Randy" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
>I know this one should be easy, but I can't make it work. I'm trying
> to dynamically define a range and assign it to a combobox on a user
> form as the rowsource. Here is my code:
>
> dim rngGrpList as Range
> Set rngGrpList = Sheet1.Range("Groups",
> Sheet1.Range("Groups").Offset.End(xlDown))
> frmManageGroups.cboGroups.RowSource = rngGrpList
>
> I'm getting a type mismatch error. It seems that my second line is
> capturing the contents of the cells rather than their addresses. I've
> played around with different ideas, but nothing seems to work. Can
> anybody see why this won't work as intended?
>
> Thanks,
> Randy
>



 
Reply With Quote
 
Randy
Guest
Posts: n/a
 
      17th Sep 2007
Sorry, it doesn't work. It doesn't like the comman in the middle of
the statement. I played with it, but couldn't make it work.

Any ideas?
Thanks.
Randy

 
Reply With Quote
 
Tim Zych
Guest
Posts: n/a
 
      17th Sep 2007
Did you copy/paste it in as posted? The line continuation character must
follow the comma. Otherwise, I'm out of steam for suggestions. It works for
me.


"Randy" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Sorry, it doesn't work. It doesn't like the comman in the middle of
> the statement. I played with it, but couldn't make it work.
>
> Any ideas?
> Thanks.
> Randy
>



 
Reply With Quote
 
Gary Keramidas
Guest
Posts: n/a
 
      17th Sep 2007
didn't test anything, but try .address after the line that errors out.

--


Gary


"Randy" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
>I know this one should be easy, but I can't make it work. I'm trying
> to dynamically define a range and assign it to a combobox on a user
> form as the rowsource. Here is my code:
>
> dim rngGrpList as Range
> Set rngGrpList = Sheet1.Range("Groups",
> Sheet1.Range("Groups").Offset.End(xlDown))
> frmManageGroups.cboGroups.RowSource = rngGrpList
>
> I'm getting a type mismatch error. It seems that my second line is
> capturing the contents of the cells rather than their addresses. I've
> played around with different ideas, but nothing seems to work. Can
> anybody see why this won't work as intended?
>
> Thanks,
> Randy
>



 
Reply With Quote
 
Randy
Guest
Posts: n/a
 
      17th Sep 2007
My bad. i didn't have the range name in quotes. Thanks. It works
perfectly.

Randy

 
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
Define a Range based on a Range object Terry Microsoft Excel Programming 4 25th Oct 2010 08:44 PM
Dynamically define variables in VB.Net/ASP.Net SV Microsoft ASP .NET 3 21st May 2008 11:53 AM
Trying to define a range for a graph dynamically within a macro =?Utf-8?B?amI=?= Microsoft Excel Programming 3 21st Mar 2007 08:36 PM
Re: How to dynamically define the column header in dataGrid C.F. Microsoft ASP .NET 1 14th Apr 2005 10:41 AM
How to define the page margins dynamically, in a Microsoft Access Report? Nuno Almeida Microsoft Access Reports 0 15th Sep 2004 05:02 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:59 PM.