LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #23   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,514
Default Spliting digits up to fit paper form

GS has brought this to us :
Rick Rothstein expressed precisely :
Why so many lines of code? <g


Just for clarity and ease for the OP to understand (better
self-documentation), AND because this solution uses an array.

Sub ParseAmountsRick()
Dim Cell As Range
For Each Cell In Selection
Cell.Offset(, 1).Resize(, 9) = Split(Format(Replace(Replace( _
Cell.Text, ".", ""), ",", ""), "@_@_@_@_@_@_@_@_@"), "_")
Next
End Sub


I also wondered when/if you'd join in!
Very nice. It's what I'd prefer over using the array approach.

However, using Cell.Text doesn't work when the cells are formatted 'General'
and the amounts are pasted in. *Typing* 107150.25 in A1 displays as 107150.3,
indicating Excel does some 'unsolicited' rounding. Typing 2765.11 and 7025.11
displays as typed. Programmatic entry displays to precision (ie: without
rounding).

Also, the thousands separator would not be present if the value was not text
to begin with. I guess it can go either way depending on how the values were
captured, but all 3 functions convert numeric values to text anyway.

So typing 107,150.25 in A1 displays as typed (no rounding occurs) BUT the
Formula Bar does not contain the comma. In this case, Excel formats the cell
to the display thousands separator but stores the value without it.

--
Since we format the value, I'd use Cell.Value...

Sub ParseAmountsRick()
Dim Cell As Range
For Each Cell In Selection
Cell.Offset(, 1).Resize(, 9) = Split(Format(Replace( _
Cell.Value, ".", ""), "@_@_@_@_@_@_@_@_@"), "_")
Next
End Sub


Well.., all might NOT be as I stated. Seems the rounding disappeared
when the column width was AutoFit. Kind of makes the rounding issue
mute unless the data is dumped into fixed width cols.

--
Garry

Free usenet access at http://www.eternal-september.org
ClassicVB Users Regroup! comp.lang.basic.visual.misc


 
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 you change single digits to recognized double digits? Evil with a K[_2_] Excel Worksheet Functions 5 April 3rd 23 02:29 PM
divide numbers up for a paper form Revenue Excel Worksheet Functions 2 August 23rd 11 11:29 PM
VBA write macro change column with 3 number digits to 4 digits the James C[_2_] Excel Discussion (Misc queries) 3 January 25th 10 03:12 PM
Mattter typed on Legal paper want to get it on A4 size paper Harish Excel Programming 1 April 22nd 09 07:13 AM
Can I scan an existing paper form into excel accounting Excel Discussion (Misc queries) 3 January 25th 07 06:13 PM


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