View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default Custom Userforms

Public bBlockEvents as Boolean


Private Sub Textbox1_Change()
Dim cnt as Long
if bBlockEvents then exit sub
cnt = len(Textbox1.Value)
if cnt 50 then
bBlockevents = True
me.Testbox1.Value = Left(Textbox1.Value,50)
me. label1 = "50/50"
bBlockEvents = False
else
me.label1 = cnt & "/50"
end if
End Sub

--
Regards,
Tom Ogilvy


"jnf40" wrote in message
...
Thanks. Can you also step me through the updating the label. I know how to
set it up to limit the number of characters allowed in the textbox.

"Tom Ogilvy" wrote:

Use the selection change event.

Right click on the sheet tab and select view code.

In the left dropdown at the top of the module select Worksheet
in the right dropdown at the top of the module select SelectionChange

this will place the declaration in the module.
Private Sub Worksheet_SelectionChange(ByVal Target As Range)

End Sub

you can put your code he

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
if Target.Address = "$A$1" then
Userform1.Show
End if
End Sub

--
Regards,
Tom Ogilvy



"jnf40" wrote in message
...
Thanks, that will help with the 50 characters, now is there a way to

get
the
userform to automatically open when a particular cell on a worksheet

is
selected? For arguments sake let's say Range("A1").

"Tom Ogilvy" wrote:

Use the change event of the textbox to update a label and limit the

number
of characters. It fires on each key entry.

--
Regards,
Tom Ogilvy


"jnf40" wrote in message
...
I want to create a userform that shows when a particular cell is

selected
on
a worksheet. Then I need a textbox also on the userform that will

only
allow
50
characters to be entered, and I would like to be able to show the

user
how
many characters they have used while they are typing in the text

box,
like
something that shows 0/50 and as they type it would change 16/34.

Is
there
a
way these actions can be done?