Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
mark kubicki
 
Posts: n/a
Default cell custom format

I would like the cell numeric entry to appear in "( ###)" format (with
parenthesis)
ex:
(9) or (4.5)...

the entry MIGHT have decimals (ex: 4.5); however, for entries that are an
even integer (ex: 9) I want ONLY the WHOLE number without a THE DECIMAL
POINT to show
ex
(9) o.k.
(4.5) o.k.
(9.) not o.k. -note the decimal point

entering this format (###.##) forces a visible decimal point even with whole
numbers


thanks in advance,
mark


  #2   Report Post  
Dave Peterson
 
Posts: n/a
Default

I don't think you'll be able to do this with formatting alone.

But you could use an event macro that looks at the value and applies the correct
numberformat.

If you want to try this, rightclick on the worksheet tab that should have this
behavior and select view code. Paste this into the code window.

Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)

If Target.Cells.Count 1 Then Exit Sub
If Intersect(Target, Me.Range("a:a")) Is Nothing Then Exit Sub

With Target
If IsNumeric(.Value) Then
If .Value = Int(.Value) Then
.NumberFormat = "0_);(0)"
Else
.NumberFormat = "0.00_);(0.00)"
End If
End If
End With

End Sub

I used column A for my input range. Change this to what you need.

If you're new to macros, you may want to read David McRitchie's intro at:
http://www.mvps.org/dmcritchie/excel/getstarted.htm

You can read more about these kinds of events at:
Chip Pearson's site:
http://www.cpearson.com/excel/events.htm

David McRitchie's site:
http://www.mvps.org/dmcritchie/excel/event.htm

mark kubicki wrote:

I would like the cell numeric entry to appear in "( ###)" format (with
parenthesis)
ex:
(9) or (4.5)...

the entry MIGHT have decimals (ex: 4.5); however, for entries that are an
even integer (ex: 9) I want ONLY the WHOLE number without a THE DECIMAL
POINT to show
ex
(9) o.k.
(4.5) o.k.
(9.) not o.k. -note the decimal point

entering this format (###.##) forces a visible decimal point even with whole
numbers

thanks in advance,
mark


--

Dave Peterson
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
how do I format a cell reference to move as source changes KGray Excel Worksheet Functions 1 August 13th 05 12:41 AM
How to refer to a cell format code? A difficult problem Excel Discussion (Misc queries) 1 May 25th 05 08:42 AM
format cell from data input to output form Brad Stevenson Excel Worksheet Functions 2 May 19th 05 06:04 PM
Show Blank is cell value=0 but count as a zero in sum. How to format this cell ? Markus Obermayer Excel Worksheet Functions 1 January 4th 05 08:01 PM
GET.CELL Biff Excel Worksheet Functions 2 November 24th 04 07:16 PM


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

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"