Define Range Dynamically

  • Thread starter Thread starter Randy
  • Start date Start date
R

Randy

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
 
Does this help?

Sheet1.Range(Sheet1.Range("Groups")(1, 1), _
Sheet1.Range("Groups")(1, 1).End(xlDown)).Name = "Groups"
frmManageGroups.cboGroups.RowSource = "Groups"
 
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
 
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.
 
didn't test anything, but try .address after the line that errors out.
 
My bad. i didn't have the range name in quotes. Thanks. It works
perfectly.

Randy
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top