Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 2
Default Excel Simple Number Formatting

Would like to create a simple cell with 16 numeric characters which would be
layed out in the format of 1234 5678 9012 3456. When attempt to do this
either unable to achieve spacing or the application exponentiates as more
than 12 characters resulting in the last digit being rounded when it is
actually required to display as it was keyed.

Appreciate any suggestions, have spent considerable time trying to resolve
but so far to no avail
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 35,218
Default Excel Simple Number Formatting

Excel keeps track of 15 significant digits. After 15, the rest turn to 0's.

You can enter the data as text by...

Preformatting the cell as text
starting the entry with an apostrophe ('1234123412341234)

Saved from another post:

Type this in A1:
'1234123412341234

and use this in that helper column:
=mid(a1,1,4)&" "&mid(a1,5,4)&" "&mid(a1,9,4)&" "&mid(a1,13,4)

or you could use a worksheet event that does the work for you.

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

Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)

Dim myTempVal As Variant

On Error GoTo errhandler:

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

myTempVal = CDec(Target.Value)
Application.EnableEvents = False
Target.Value = Format(myTempVal, "0000 0000 0000 0000")

errhandler:
Application.EnableEvents = True

End Sub

I used all of column A in this line:
If Intersect(Target, Me.Range("a:a")) Is Nothing Then Exit Sub
but you could use:
If Intersect(Target, Me.Range("c7:g99")) Is Nothing Then Exit Sub

But make sure whatever range you use is preformatted to text. If you leave it
general, then that 16th digit is already a 0 when the code starts.

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

Rand wrote:

Would like to create a simple cell with 16 numeric characters which would be
layed out in the format of 1234 5678 9012 3456. When attempt to do this
either unable to achieve spacing or the application exponentiates as more
than 12 characters resulting in the last digit being rounded when it is
actually required to display as it was keyed.

Appreciate any suggestions, have spent considerable time trying to resolve
but so far to no avail


--

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
Return SEARCHED Column Number of Numeric Label and Value Sam via OfficeKB.com Excel Worksheet Functions 23 January 30th 06 06:16 PM
How do I set up a number to 1,23,459.00 formatting in excel? Shiji Excel Discussion (Misc queries) 1 January 11th 06 07:10 AM
Excel not taking number format consistently KP Conrad Excel Discussion (Misc queries) 1 September 22nd 05 07:37 PM
Excel 2003 random number generator JJ Excel Discussion (Misc queries) 1 May 4th 05 01:02 PM
Conditional formatting not available in Excel BAB Excel Discussion (Misc queries) 2 January 1st 05 03:33 PM


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

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

About Us

"It's about Microsoft Excel"