Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
MST MST is offline
external usenet poster
 
Posts: 2
Default Use cell values as object names

I'm trying to ".Show" a user form by using a cell value as the UserForm name.
The user forms are already created and the "(Name)" property of each form is
included in a list on a worksheet. I would like to use the "SelectionChange"
event to "Show" the user form that matches the value of the cell the user
selects. My problem is getting the cell value (string) into the proper
format for
the Show statement: "(substitute cell value here).Show"
Can anyone provide the secret to getting a string value to work as a
legitimate
object name (UserForm in this case)?

Thanks.

MST
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Use cell values as object names

Assuming that the names of the userforms are in cells A1:A3, use code like

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Not Application.Intersect(Target, Range("A1:A3")) Is Nothing Then
With VBA.UserForms
Do Until .Count = 0
.Item(0).Delete
Loop
.Add Target.Text
.Item(0).Show
End With
End If
End Sub


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting
www.cpearson.com
(email on the web site)


"MST" wrote in message
...
I'm trying to ".Show" a user form by using a cell value as the UserForm
name.
The user forms are already created and the "(Name)" property of each form
is
included in a list on a worksheet. I would like to use the
"SelectionChange"
event to "Show" the user form that matches the value of the cell the user
selects. My problem is getting the cell value (string) into the proper
format for
the Show statement: "(substitute cell value here).Show"
Can anyone provide the secret to getting a string value to work as a
legitimate
object name (UserForm in this case)?

Thanks.

MST


  #3   Report Post  
Posted to microsoft.public.excel.programming
MST MST is offline
external usenet poster
 
Posts: 2
Default Use cell values as object names

That works. Thanks. I never would have figured it out on my own

MST

"Chip Pearson" wrote:

Assuming that the names of the userforms are in cells A1:A3, use code like

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Not Application.Intersect(Target, Range("A1:A3")) Is Nothing Then
With VBA.UserForms
Do Until .Count = 0
.Item(0).Delete
Loop
.Add Target.Text
.Item(0).Show
End With
End If
End Sub


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting
www.cpearson.com
(email on the web site)


"MST" wrote in message
...
I'm trying to ".Show" a user form by using a cell value as the UserForm
name.
The user forms are already created and the "(Name)" property of each form
is
included in a list on a worksheet. I would like to use the
"SelectionChange"
event to "Show" the user form that matches the value of the cell the user
selects. My problem is getting the cell value (string) into the proper
format for
the Show statement: "(substitute cell value here).Show"
Can anyone provide the secret to getting a string value to work as a
legitimate
object name (UserForm in this case)?

Thanks.

MST


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
tab names from cell values cursednomore Excel Discussion (Misc queries) 5 January 3rd 07 07:24 PM
List of property names and values for a given Object MichaelMalone Excel Programming 4 September 20th 05 03:19 PM
List of property names and values for a given object. MichaelMalone Excel Worksheet Functions 0 September 16th 05 09:49 PM
Populate cell values with sheet names Bob Kilmer Excel Programming 0 August 13th 04 06:30 PM
Creating worksheets with cell values as names Bob Excel Programming 4 July 23rd 04 04:00 AM


All times are GMT +1. The time now is 04:30 PM.

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

About Us

"It's about Microsoft Excel"