Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Controls Question
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 |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Controls Question
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 |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Controls Question
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 |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Controls Question
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 |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
Controls Question
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 |
#6
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
#7
Posted to microsoft.public.excel.programming
|
|||
|
|||
Controls Question
again, thank you for your help -- I did as you last suggested and all is
well. ny list name is actually a named range within the excel file and it is referred to as "ListName". This part works fine. "Dave Peterson" wrote: 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 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Question for Peter T - Copy Paste controls at runtime | Excel Programming | |||
User controls on sheet question. - How to toggle between design and execute mode? | Excel Programming | |||
Event procedures for controls added with Controls.Add | Excel Programming | |||
Learning Macros and ActiveX controls...have a simple question... | Excel Programming | |||
General question: how many controls allowed? | Excel Programming |