View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.programming
Dave Peterson Dave Peterson is offline
external usenet poster
 
Posts: 35,218
Default Controls Question

I would remove the characters "formname" from yVariable:

yVariable = "XControl"

Then use:
formname.controls(yVariable).rowsource = listname

But now I'm worried about what listname is.

Does listname look like an address?

dim ListName as string
listname = worksheets("Somesheet").range("a1:a10").address(ex ternal:=true)

or what???????


Sandy wrote:

I am sorry this is so confusing -- but it does show that I don't know how to
do this -- I appreciate your help.

The name of the control is FormName.XControl it is stored in a variable
called YVariable

YVariable = "FormName.XControl"

I want to be able to say the rowsource for the control whose name is stored
in YVariable is = "ListName"

"Dave Peterson" wrote:

Ahhh. YVariable is the name of the control--not a variable that represents the
control itself.

dim yVariable as string
yVariable = "somestring"

formname.controls(yVariable).rowsource = listname

(maybe???????)

If this code is behind the userform itself, I'd use:
me.controls(yVariable).rowsource = listname

Me represents the object that owns the code--in this case, it would be that
userform.

Sandy wrote:

Thank you.

Yes, the 1st line works ok.

The name of the control that I want to set the row source for is already
stored in the memory variable called YVariable ("FormName.XControl").

After that I don't know how to refer to the control via the contents of
Yvariable.

"Dave Peterson" wrote:

The first line worked ok?
FormName.xControl.RowSource = ListName

Then did you do something like:

Set yVariable = FormName.xControl
yvariable.rowsource = listname

If it didn't work, you may want to share more of your code.

Sandy wrote:

I have the name of a control ("FormName.XControl") stored in a memory
variable (YVariable) I want to set the row source of xControl by referring to
the variable YVariable.

Instead of FormName.xControl.RowSource = ListName I want
YVariable.rowsource = ListName

How do I accomplish this?

Thank you

--

Dave Peterson


--

Dave Peterson


--

Dave Peterson