refer to a listbox by a string value?

Fyr

Active Member
Joined
Jan 20, 2009
Messages
375
Here's what I'm trying to do.
Set a custom document property ThisWorkbook.CustomDocumentProperties("_DOCPROPNAME") the name of a listbox (Listbox1).
Code:
ThisWorkbook.CustomDocumentProperties("_DOCPROPNAME") = "LISTBOX1"

Then when trying to refer to the listbox from a worksheet use
Code:
Userform1."ThisWorkbook.CustomDocumentProperties("_DOCPROPNAME")"

I know this will not work, but is something like this possible?
 

Some videos you may like

Excel Facts

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce

RoryA

MrExcel MVP, Moderator
Joined
May 2, 2008
Messages
35,503
Office Version
  1. 365
  2. 2019
  3. 2016
  4. 2010
Platform
  1. Windows
  2. MacOS
You need something like:
Code:
Userform1.Controls(ThisWorkbook.CustomDocumentProperties("_DOCPROPNAME"))
or:
Code:
CallByName(Userform1, ThisWorkbook.CustomDocumentProperties("_DOCPROPNAME"), VbGet)
 

Watch MrExcel Video

Forum statistics

Threads
1,108,989
Messages
5,526,091
Members
409,685
Latest member
Bellybb

This Week's Hot Topics

Top