Control User Form object properties from VBA code
You'll have to extrapolate in case 2007 works differently but here's some
feedback based on XL2003.
I added a forms object listbox to a worksheet
In the worksheet code sheet, I added:
Sub testchange()
ListBox1.ListFillRange = "A5:A9"
End Sub
And that worked to change the source range from code.
Is your code behind the target worksheet, or in a module? What triggers the
execution of the code? Is your source range a range on the same sheet, a
different sheet, or a named range?
Please post more information and your code samples, if you can't get it
working.
HTH,
Keith
"Nikko963" wrote:
Hello all.
I have just spent the last 2.5 hours trying to figure out how to do this and
am at the end of my rope. Excel help is no use (big surprise!), my Excel
reference book contains no code examples (gotta get me a complete Excel VBA
Reference guide), and everything I have found on the Web doesn't apply to me
or is too confusing for an intermediate, occasional programmer like me. The
irony is that my need seems fairly simple.
I have an Excel 2007 spreadsheet. One of the cells has a list box (the
official property name is 'MyListBox') whose Input Range I want to change
based on a user's selection elsewhere in this form. Note that the list box
was added as a Form Object, NOT an ActiveX Object. The list box nor the cell
it is in will be selected at the time the code needs to change the list box's
properties.
What would the code look like to change the current Input Range from AA1:AA3
to AB1:AB3?
You see? Simple request!
Thanks in advance.
|