Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 32
Default Please help... real simple question...

Hey,

I am trying to refrence the name of an object on my userform... I have
setup a combobox with the values 1 - 10... the end result is when
someone selects a value it creates the the string of text "TextBox" &
X (X = number selected from combobox). I then have code that I want to
select that object based on the value of generated... any help is
greatly appreciated!!!

Private Sub ComboBox2_Change()
UserForm1.TextBox8.Value = "TextBox" & ComboBox2.Value
End Sub

Private Sub CommandButton14_Click()
Dim ZoneX As String
ZoneX = UserForm1.TextBox8.Value
ZoneX.SetFocus
End Sub

Why does this not work?
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 32
Default Please help... real simple question...

On Jan 13, 10:05*pm, Dave Peterson wrote:
Maybe...

Private Sub ComboBox2_Change()
* *'Me is a keyword that refers to the object that owns the code.
* *'in this case, it's the userform
* *Me.TextBox8.Value = me.controls("TextBox" & me.ComboBox2.Value).value
End Sub





wrote:

Hey,


I am trying to refrence the name of an object on my userform... I have
setup a combobox with the values 1 - 10... the end result is when
someone selects a value it creates the the string of text "TextBox" &
X (X = number selected from combobox). I then have code that I want to
select that object based on the value of generated... any help is
greatly appreciated!!!


Private Sub ComboBox2_Change()
UserForm1.TextBox8.Value = "TextBox" & ComboBox2.Value
End Sub


Private Sub CommandButton14_Click()
Dim ZoneX As String
ZoneX = UserForm1.TextBox8.Value
ZoneX.SetFocus
End Sub


Why does this not work?


--

Dave Peterson- Hide quoted text -

- Show quoted text -


Awsome!!! Thanks!
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,549
Default Please help... real simple question...

Hey yourself,
It doesn't work because you are trying to set focus to a String.
SetFocus applies to objects. Try...
Me.Controls(ZoneX).SetFocus
--
Jim Cone
Portland, Oregon USA




wrote in message
Hey,
I am trying to refrence the name of an object on my userform... I have
setup a combobox with the values 1 - 10... the end result is when
someone selects a value it creates the the string of text "TextBox" &
X (X = number selected from combobox). I then have code that I want to
select that object based on the value of generated... any help is
greatly appreciated!!!

Private Sub ComboBox2_Change()
UserForm1.TextBox8.Value = "TextBox" & ComboBox2.Value
End Sub

Private Sub CommandButton14_Click()
Dim ZoneX As String
ZoneX = UserForm1.TextBox8.Value
ZoneX.SetFocus
End Sub

Why does this not work?
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
Hopefully a real easy vba question Brad Excel Discussion (Misc queries) 2 November 18th 09 09:50 PM
The real Horizontal Formula question Melissa in Salem Excel Discussion (Misc queries) 4 June 14th 09 02:06 AM
This may be real simple, but... Cerberus Excel Discussion (Misc queries) 6 March 18th 08 08:01 PM
Question for the real experts! diepenbos Excel Discussion (Misc queries) 2 March 16th 05 03:21 PM
Real simple VBA not sure why I cannot paste. Jason Excel Programming 2 April 7th 04 07:11 PM


All times are GMT +1. The time now is 06:57 AM.

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"