ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Advanced Formatting (https://www.excelbanter.com/excel-programming/342543-advanced-formatting.html)

[email protected]

Advanced Formatting
 
Does anybody know how to apply a special formatting to a cell in a way
that if "1" was typed in it it will display "1 Child" but if 2 or 3 or
4 was typed it shows "2 Childs" or "3 Childs" ....

Thank you


Harald Staff

Advanced Formatting
 
Hi

No can do with formatting. Macro work. Rightclick the sheet tab, choose
"view code", paste the following into the blank moule:

Private Sub Worksheet_Change(ByVal Target As Range)
Dim L As Long
With Target(1)
L = Val(.Value)
Application.EnableEvents = False
Select Case L
Case 0
.Value = "No kids"
Case 1
.Value = L & " Child"
Case Else
.Value = L & " Childs"
End Select
Application.EnableEvents = True
End With
End Sub

HTH. Best wishes Harald

skrev i melding
oups.com...
Does anybody know how to apply a special formatting to a cell in a way
that if "1" was typed in it it will display "1 Child" but if 2 or 3 or
4 was typed it shows "2 Childs" or "3 Childs" ....

Thank you




Bob Phillips[_6_]

Advanced Formatting
 
Try a format of

[1]0" Childs";[0]0" Child";General

--
HTH

Bob Phillips

wrote in message
oups.com...
Does anybody know how to apply a special formatting to a cell in a way
that if "1" was typed in it it will display "1 Child" but if 2 or 3 or
4 was typed it shows "2 Childs" or "3 Childs" ....

Thank you




Harald Staff

Advanced Formatting
 
Wohoo. I stand corrected. Thanks Bob.

Best wishes Harald

"Bob Phillips" skrev i melding
...
Try a format of

[1]0" Childs";[0]0" Child";General




William Benson[_2_]

Advanced Formatting
 
May I suggest an alternative:

[<1]0" Children";[=0]0" Child";General

to follow correct grammar:

0 children
1 child
2 or more children


"Harald Staff" wrote in message
...
Wohoo. I stand corrected. Thanks Bob.

Best wishes Harald

"Bob Phillips" skrev i melding
...
Try a format of

[1]0" Childs";[0]0" Child";General






Dave Peterson

Advanced Formatting
 
I cheat...

# Child(ren)

(but you may want to use Children instead of Childs when you use Bob's
suggestion.)

wrote:

Does anybody know how to apply a special formatting to a cell in a way
that if "1" was typed in it it will display "1 Child" but if 2 or 3 or
4 was typed it shows "2 Childs" or "3 Childs" ....

Thank you


--

Dave Peterson

Bob Phillips[_6_]

Advanced Formatting
 
LOL. Guilty ... just answered the question.

Bob

"William Benson" wrote in message
...
May I suggest an alternative:

[<1]0" Children";[=0]0" Child";General

to follow correct grammar:

0 children
1 child
2 or more children


"Harald Staff" wrote in message
...
Wohoo. I stand corrected. Thanks Bob.

Best wishes Harald

"Bob Phillips" skrev i melding
...
Try a format of

[1]0" Childs";[0]0" Child";General









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

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