Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Highlight Value of Text Box
I have a UserForm with four textboxes names py1 py2 py3 py4
What I am trying to accomplish is that when a user clicks into a textbox, it will loop through the other three add their values and subtract it from a Total, and put that value into the textbox. This part I have accomplished with no problem. However when it puts that value into the textbox the user has clicked into i want to HIGHLIGHT the value that was entered into textbox through VBA ..selstart & .sellength will not select it code follows Private Sub py1_Enter() Dim t As Integer toy = 0 Set ctl1 = Me.ActiveControl For t = 1 To 4 Set ctll = Me.Controls("py" + Trim(Str(t))) If ctl1.Name < ctll.Name Then toy = toy + Val(ctll.Text) Next With ctl1 ..Text = Trim(Str(tow - toy)) ..SelStart = 0 ..SelLength = Len(.Text) End With End Sub the code is EXACTLY the same for each text box the two variables ctll & ctl1 are public in the userform. anyone see why maybe the userform will not highlight the text? -- When you lose your mind, you free your life. |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Highlight Value of Text Box
Hi i think you need to SetFocus = Textbox? or something along thos lines Simo -- Simon Lloy ----------------------------------------------------------------------- Simon Lloyd's Profile: http://www.excelforum.com/member.php...nfo&userid=670 View this thread: http://www.excelforum.com/showthread.php?threadid=37868 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Highlight specific text | Excel Discussion (Misc queries) | |||
No Text Highlight in Excel ?? | Excel Discussion (Misc queries) | |||
Highlight text | Excel Discussion (Misc queries) | |||
Text Highlight | Excel Programming | |||
highlight cell text | Excel Programming |