ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   about the dot standing alone (https://www.excelbanter.com/excel-discussion-misc-queries/135226-about-dot-standing-alone.html)

David Biddulph[_2_]

about the dot standing alone
 
Why not format as General?
--
David Biddulph

"santhagr" wrote in message
oups.com...
i don't know how to make a format in order to place the dot and the
digits that follow if there are any and if there aren't NOT to have a
dot standing there alone.

so far i put the special format: ### ### ###.## but there is a dot
alone
and if i put : ### ### ###_0_0 it rounds the number up

do u have any idea??




santhagr

about the dot standing alone
 
i don't know how to make a format in order to place the dot and the
digits that follow if there are any and if there aren't NOT to have a
dot standing there alone.

so far i put the special format: ### ### ###.## but there is a dot
alone
and if i put : ### ### ###_0_0 it rounds the number up

do u have any idea??


santhagr

about the dot standing alone
 
i want to have the spaces also: 1 200 400 not 1200400


Dave Peterson

about the dot standing alone
 
You won't be able to do this with numberformatting alone.

If the values are typed in (not the results of a formula), you could use an
event macro. Rightclick on the worksheet tab that should have this behavior.
Select view code and paste this in the code window:

Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)
With Target
If .Cells.Count 1 Then Exit Sub
If Intersect(.Cells, Me.Range("a:a")) Is Nothing Then
Exit Sub
End If

If Int(.Value) = .Value Then
'no decimal places
.NumberFormat = "### ### ###"
'or maybe
'.NumberFormat = "### ### ###_._0_0"
Else
.NumberFormat = "### ### ###.##"
'or maybe
'.NumberFormat = "### ### ###.00"
End If
End With
End Sub

Then back to excel to test it out. I adjusted the cells in column A. Change it
to what you want. If the values change as the result of a formula
recalculation, a different event (with small differences in code) could be used.

The 'or maybe versions may be nice if you want the (assumed) decimal places to
align.

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 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

santhagr wrote:

i don't know how to make a format in order to place the dot and the
digits that follow if there are any and if there aren't NOT to have a
dot standing there alone.

so far i put the special format: ### ### ###.## but there is a dot
alone
and if i put : ### ### ###_0_0 it rounds the number up

do u have any idea??


--

Dave Peterson


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

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