named range as rowsource
When I get an error I try to break the problem into pieces. I defined a name
in the spreadsheet then tried the statement below and it failed
Set a = Range("PoolTypes")
Then I tried the code below and it worked.
Set a = ActiveSheet.Range("PoolTypes")
or
Set a = Sheets("Sheet1").Range("PoolTypes")
There are a lot of functions and metods that I do not have memorized. I
thought name in VBA needed a worksheet reference, but wasn't sure. So I ran
a test to be sure before giving you advice.
"Karen53" wrote:
Hi,
I have a listbox that I am trying to set the rowsource with VBA. If I set
the rowsource manually in the properties window to mynameedrange, my code
works great. I'm having trouble with the code setting it with VBA.
Here's what I have:
With frmPoolTypes.lstPoolList
.RowSource = Range("PoolTypes")
.BoundColumn = 1
.ColumnCount = 1
.ListStyle = fmListStyleOption
End With
What am I doing wrong?
Thanks,
|