ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Text Counter as you type (https://www.excelbanter.com/excel-programming/362534-text-counter-you-type.html)

jeffbert

Text Counter as you type
 
Is there a way to make a cell have a character counter? The cell is validated
to only allow 30 characters. I need to put in a counter that as the person
types, it shows they are on character "13/50" and keeps counting as they type.


Tom Ogilvy

Text Counter as you type
 
macros don't run (for any practical purpose) while a user is editing a cell.

--
Regards,
Tom Ogilvy


"jeffbert" wrote:

Is there a way to make a cell have a character counter? The cell is validated
to only allow 30 characters. I need to put in a counter that as the person
types, it shows they are on character "13/50" and keeps counting as they type.


jeffbert

Text Counter as you type
 
So if I entered a text box, would this be possible?

If not, what is the most practical way to achive this?



"Tom Ogilvy" wrote:

macros don't run (for any practical purpose) while a user is editing a cell.

--
Regards,
Tom Ogilvy


"jeffbert" wrote:

Is there a way to make a cell have a character counter? The cell is validated
to only allow 30 characters. I need to put in a counter that as the person
types, it shows they are on character "13/50" and keeps counting as they type.


Tom Ogilvy

Text Counter as you type
 
Yes. A textbox from the control toolbox toolbar has a Change event that
fires on each keystroke, so this would support what you want to do.

--
Regards,
Tom Ogilvy


"jeffbert" wrote:

So if I entered a text box, would this be possible?

If not, what is the most practical way to achive this?



"Tom Ogilvy" wrote:

macros don't run (for any practical purpose) while a user is editing a cell.

--
Regards,
Tom Ogilvy


"jeffbert" wrote:

Is there a way to make a cell have a character counter? The cell is validated
to only allow 30 characters. I need to put in a counter that as the person
types, it shows they are on character "13/50" and keeps counting as they type.


jeffbert

Text Counter as you type
 
Not to wear out your patience, but I am an extreme novice in VB. Do you have
a sample of the code I could manipulate?

Thanks again


"Tom Ogilvy" wrote:

Yes. A textbox from the control toolbox toolbar has a Change event that
fires on each keystroke, so this would support what you want to do.

--
Regards,
Tom Ogilvy


"jeffbert" wrote:

So if I entered a text box, would this be possible?

If not, what is the most practical way to achive this?



"Tom Ogilvy" wrote:

macros don't run (for any practical purpose) while a user is editing a cell.

--
Regards,
Tom Ogilvy


"jeffbert" wrote:

Is there a way to make a cell have a character counter? The cell is validated
to only allow 30 characters. I need to put in a counter that as the person
types, it shows they are on character "13/50" and keeps counting as they type.


Tom Ogilvy

Text Counter as you type
 
put in a textbox from the control toolbox toolbar

Right click on it and select view code.

Put in code like this: (assumes the name is Textbox1)

Private Sub TextBox1_Change()
If Len(TextBox1.Text) 30 Then
TextBox1.Value = Left(TextBox1.Text, 30)
End If
Set rng = TextBox1.TopLeftCell.Offset(0, -1)
rng.Value = "'" & Len(TextBox1.Text) & "/30"
End Sub

--
regards,
Tom Ogilvy


"jeffbert" wrote:

Not to wear out your patience, but I am an extreme novice in VB. Do you have
a sample of the code I could manipulate?

Thanks again


"Tom Ogilvy" wrote:

Yes. A textbox from the control toolbox toolbar has a Change event that
fires on each keystroke, so this would support what you want to do.

--
Regards,
Tom Ogilvy


"jeffbert" wrote:

So if I entered a text box, would this be possible?

If not, what is the most practical way to achive this?



"Tom Ogilvy" wrote:

macros don't run (for any practical purpose) while a user is editing a cell.

--
Regards,
Tom Ogilvy


"jeffbert" wrote:

Is there a way to make a cell have a character counter? The cell is validated
to only allow 30 characters. I need to put in a counter that as the person
types, it shows they are on character "13/50" and keeps counting as they type.


jeffbert

Text Counter as you type
 
Works beautifully. Thanks again.


"Tom Ogilvy" wrote:

put in a textbox from the control toolbox toolbar

Right click on it and select view code.

Put in code like this: (assumes the name is Textbox1)

Private Sub TextBox1_Change()
If Len(TextBox1.Text) 30 Then
TextBox1.Value = Left(TextBox1.Text, 30)
End If
Set rng = TextBox1.TopLeftCell.Offset(0, -1)
rng.Value = "'" & Len(TextBox1.Text) & "/30"
End Sub

--
regards,
Tom Ogilvy


"jeffbert" wrote:

Not to wear out your patience, but I am an extreme novice in VB. Do you have
a sample of the code I could manipulate?

Thanks again


"Tom Ogilvy" wrote:

Yes. A textbox from the control toolbox toolbar has a Change event that
fires on each keystroke, so this would support what you want to do.

--
Regards,
Tom Ogilvy


"jeffbert" wrote:

So if I entered a text box, would this be possible?

If not, what is the most practical way to achive this?



"Tom Ogilvy" wrote:

macros don't run (for any practical purpose) while a user is editing a cell.

--
Regards,
Tom Ogilvy


"jeffbert" wrote:

Is there a way to make a cell have a character counter? The cell is validated
to only allow 30 characters. I need to put in a counter that as the person
types, it shows they are on character "13/50" and keeps counting as they type.



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

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com