Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Evaluate and execute a string

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   Report Post  
Posted to microsoft.public.excel.programming
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!




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,339
Default Evaluate and execute a string

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Thank you!!

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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Is there a function that will evaluate a text string in a cell? Dave Excel Worksheet Functions 2 October 7th 09 04:25 AM
Evaluate text string as a function benb Excel Discussion (Misc queries) 3 July 19th 06 02:41 PM
Evaluate string as a formula peacelittleone Excel Worksheet Functions 3 June 26th 05 06:20 PM
how to evaluate the content of a string as if it was a formula cyrille de brébisson Excel Discussion (Misc queries) 5 December 6th 04 10:47 PM
VBA Function to evaluate hlookup text string as formula Eric[_22_] Excel Programming 2 August 2nd 04 04:57 PM


All times are GMT +1. The time now is 12:08 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"