#1   Report Post  
Lara Shook
 
Posts: n/a
Default custom formatting

I want my list of data to appear like this:

234.1
1234
1234.2
234

with the decimal points lining up, but with NO Decimal point SHOWING if it's
a whole number.

I tried this format: ????.?

but the decimal point still shows:

234.1
1234.
1234.2
234.

Does anyone know how to make the decimal point go away (for whole numbers),
but still get the column to line up there? Thanks.
  #2   Report Post  
Dave Peterson
 
Posts: n/a
Default

I don't think you're going to get it using the number format.

But you could use a worksheet event. If you're typing the values in, you can
use something like this:

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 CLng(.Value) = .Value Then
.NumberFormat = "##0_._?"
Else
.NumberFormat = "##0.?"
End If
End If
End With
End Sub

Right click on the worksheet tab that should have this behavior. Select view
code and paste this into the code window.

I used column A in my code.

Change this to what you need.
If Intersect(Target, Me.Range("a:a")) Is Nothing Then Exit Sub


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



Lara Shook wrote:

I want my list of data to appear like this:

234.1
1234
1234.2
234

with the decimal points lining up, but with NO Decimal point SHOWING if it's
a whole number.

I tried this format: ????.?

but the decimal point still shows:

234.1
1234.
1234.2
234.

Does anyone know how to make the decimal point go away (for whole numbers),
but still get the column to line up there? Thanks.


--

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
Custom Formatting a number Hari Prasadh Excel Discussion (Misc queries) 8 January 22nd 05 01:40 PM
Formatting dates in the future Compass Rose Excel Worksheet Functions 3 January 17th 05 10:39 PM
Custom Number formatting gizmo Excel Worksheet Functions 3 January 8th 05 01:07 AM
Conditional formatting not available in Excel BAB Excel Discussion (Misc queries) 2 January 1st 05 03:33 PM
Custom formatting Pat Excel Discussion (Misc queries) 1 December 16th 04 12:15 PM


All times are GMT +1. The time now is 05:17 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"