View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Bernie Deitrick Bernie Deitrick is offline
external usenet poster
 
Posts: 5,441
Default Evaluate and execute a string

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!