![]() |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
All times are GMT +1. The time now is 02:35 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com