Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I am trying to take the selected text from one listbox and add it to a
separate listbox. Something like this: UserForm1.lstEmployee.AddItem (lstCompanyA.Text) The problem is that the name of the listbox that I am taking from (lstCompanyA) is contained within a string variable. So I have tried this: Dim strTest As String strTest = "UserForm1.lstEmployee.AddItem (" & strCompName & ".Text)" Evaluate (strTest) But I don't think I can do that using the Evaluate method. Is there other way to do this? Thanks in advance for any suggestions! |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Use the controls collection, along the lines of
UserForm1.lstEmployee.AddItem UserForm1.Controls(strCompName).Text HTH, Bernie MS Excel MVP "Randall" wrote in message ... I am trying to take the selected text from one listbox and add it to a separate listbox. Something like this: UserForm1.lstEmployee.AddItem (lstCompanyA.Text) The problem is that the name of the listbox that I am taking from (lstCompanyA) is contained within a string variable. So I have tried this: Dim strTest As String strTest = "UserForm1.lstEmployee.AddItem (" & strCompName & ".Text)" Evaluate (strTest) But I don't think I can do that using the Evaluate method. Is there other way to do this? Thanks in advance for any suggestions! |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Try:
UserForm1.ListBox2.AddItem Me.Controls(strCompName).Text HTH "Randall" wrote: I am trying to take the selected text from one listbox and add it to a separate listbox. Something like this: UserForm1.lstEmployee.AddItem (lstCompanyA.Text) The problem is that the name of the listbox that I am taking from (lstCompanyA) is contained within a string variable. So I have tried this: Dim strTest As String strTest = "UserForm1.lstEmployee.AddItem (" & strCompName & ".Text)" Evaluate (strTest) But I don't think I can do that using the Evaluate method. Is there other way to do this? Thanks in advance for any suggestions! |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Thanks for both replies--"Controls" does exactly what I was looking for!
"Randall" wrote in message ... I am trying to take the selected text from one listbox and add it to a separate listbox. Something like this: UserForm1.lstEmployee.AddItem (lstCompanyA.Text) The problem is that the name of the listbox that I am taking from (lstCompanyA) is contained within a string variable. So I have tried this: Dim strTest As String strTest = "UserForm1.lstEmployee.AddItem (" & strCompName & ".Text)" Evaluate (strTest) But I don't think I can do that using the Evaluate method. Is there other way to do this? Thanks in advance for any suggestions! |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Is there a function that will evaluate a text string in a cell? | Excel Worksheet Functions | |||
Evaluate text string as a function | Excel Discussion (Misc queries) | |||
Evaluate string as a formula | Excel Worksheet Functions | |||
how to evaluate the content of a string as if it was a formula | Excel Discussion (Misc queries) | |||
VBA Function to evaluate hlookup text string as formula | Excel Programming |