Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
c62ip64
 
Posts: n/a
Default format inplied decimal point

I am importing a fixed length text file containing numeric data with an
implied decimal point. I want to format the worksheet column to include the
decimal point. E.g. text file '000012345', worksheet column '0000123.45'

I can format the column as numeric to include the decimal point and divide
the value by 100 to get the precision. I am not sure how to define the
calculation for the column.

I'm assuming that dividing by 100 is the easiest way to do this. Let me know
if there is an easier way.

Thanks,
Tom
  #2   Report Post  
Dave Peterson
 
Posts: n/a
Default format inplied decimal point

If you're doing this by hand, you can find an empty cell.
Put 100 in that cell
edit|copy that cell
select the range to fix
edit|paste special|check divide
Then clean up that helper cell (with 100 in it).

In code, it could look something like:

Option Explicit
Sub testme()

Dim myRng As Range
Dim myCell As Range

With ActiveSheet
Set myCell = .Cells.SpecialCells(xlCellTypeLastCell).Offset(1, 1)
myCell.Value = 100

Set myRng = .Range("e1", .Cells(.Rows.Count, "E").End(xlUp))

myCell.Copy
myRng.PasteSpecial operation:=xlPasteSpecialOperationDivide

myCell.Clear
End With

End Sub

(I used column E for my testing.)

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

c62ip64 wrote:

I am importing a fixed length text file containing numeric data with an
implied decimal point. I want to format the worksheet column to include the
decimal point. E.g. text file '000012345', worksheet column '0000123.45'

I can format the column as numeric to include the decimal point and divide
the value by 100 to get the precision. I am not sure how to define the
calculation for the column.

I'm assuming that dividing by 100 is the easiest way to do this. Let me know
if there is an easier way.

Thanks,
Tom


--

Dave Peterson
  #3   Report Post  
Ron Rosenfeld
 
Posts: n/a
Default format inplied decimal point

On Mon, 14 Nov 2005 11:47:06 -0800, "c62ip64"
wrote:

I am importing a fixed length text file containing numeric data with an
implied decimal point. I want to format the worksheet column to include the
decimal point. E.g. text file '000012345', worksheet column '0000123.45'

I can format the column as numeric to include the decimal point and divide
the value by 100 to get the precision. I am not sure how to define the
calculation for the column.

I'm assuming that dividing by 100 is the easiest way to do this. Let me know
if there is an easier way.

Thanks,
Tom


Yes, dividing by 100 is the simplest method.

You can set up a "helper column" with the formula =cell_ref/100.
Copy/Drag down as far as needed
Copy/Paste Special Values to convert the formula to numbers (pasting back over
the original).

You can also type 100 in some blank cell.
Edit/Copy the cell with the 100 in it.
Select the range of numbers to be converted.
Edit/Paste Special Divide


--ron
  #4   Report Post  
Posted to microsoft.public.excel.misc
c62ip64
 
Posts: n/a
Default format inplied decimal point

Thanks, I'm getting an 'invalid name error' when using the formula but the
second option formats the value with the decimal point placement.

I have one additional question about formatting negative values. How do I
format a negative value from the test file, '0005400}', as '-000540.00'.

Tom

"Ron Rosenfeld" wrote:

On Mon, 14 Nov 2005 11:47:06 -0800, "c62ip64"
wrote:

I am importing a fixed length text file containing numeric data with an
implied decimal point. I want to format the worksheet column to include the
decimal point. E.g. text file '000012345', worksheet column '0000123.45'

I can format the column as numeric to include the decimal point and divide
the value by 100 to get the precision. I am not sure how to define the
calculation for the column.

I'm assuming that dividing by 100 is the easiest way to do this. Let me know
if there is an easier way.

Thanks,
Tom


Yes, dividing by 100 is the simplest method.

You can set up a "helper column" with the formula =cell_ref/100.
Copy/Drag down as far as needed
Copy/Paste Special Values to convert the formula to numbers (pasting back over
the original).

You can also type 100 in some blank cell.
Edit/Copy the cell with the 100 in it.
Select the range of numbers to be converted.
Edit/Paste Special Divide


--ron

  #5   Report Post  
Posted to microsoft.public.excel.misc
Ron Rosenfeld
 
Posts: n/a
Default format inplied decimal point

On Tue, 15 Nov 2005 06:06:01 -0800, "c62ip64"
wrote:

Thanks, I'm getting an 'invalid name error' when using the formula but the
second option formats the value with the decimal point placement.


You would get a #NAME error if the cell reference that you substituted for
cell_ref in the formula was not valid in your worksheet.


I have one additional question about formatting negative values. How do I
format a negative value from the test file, '0005400}', as '-000540.00'.


How do you know that the value is negative?


--ron


  #6   Report Post  
Posted to microsoft.public.excel.misc
c62ip64
 
Posts: n/a
Default format inplied decimal point

The sign is contained in the low order bits of the last character.
x'D0' - } translates to -0
x'D1' - J translates to -1
x'D2' - K translates to -2
x'D3' - L translates to -3
etc.

Sounds like Excel does not recognize this format and I'll need a script to
interpret the results.

Thanks,
Tom

"Ron Rosenfeld" wrote:

On Tue, 15 Nov 2005 06:06:01 -0800, "c62ip64"
wrote:

Thanks, I'm getting an 'invalid name error' when using the formula but the
second option formats the value with the decimal point placement.


You would get a #NAME error if the cell reference that you substituted for
cell_ref in the formula was not valid in your worksheet.


I have one additional question about formatting negative values. How do I
format a negative value from the test file, '0005400}', as '-000540.00'.


How do you know that the value is negative?


--ron

  #7   Report Post  
Posted to microsoft.public.excel.misc
Ron Rosenfeld
 
Posts: n/a
Default format inplied decimal point

You could probably process it using the SUBSTITUTE worksheet function. If you
post some examples of inputs and associated outputs, I can help work it out.



On Tue, 15 Nov 2005 12:38:01 -0800, "c62ip64"
wrote:

The sign is contained in the low order bits of the last character.
x'D0' - } translates to -0
x'D1' - J translates to -1
x'D2' - K translates to -2
x'D3' - L translates to -3
etc.

Sounds like Excel does not recognize this format and I'll need a script to
interpret the results.

Thanks,
Tom

"Ron Rosenfeld" wrote:

On Tue, 15 Nov 2005 06:06:01 -0800, "c62ip64"
wrote:

Thanks, I'm getting an 'invalid name error' when using the formula but the
second option formats the value with the decimal point placement.


You would get a #NAME error if the cell reference that you substituted for
cell_ref in the formula was not valid in your worksheet.


I have one additional question about formatting negative values. How do I
format a negative value from the test file, '0005400}', as '-000540.00'.


How do you know that the value is negative?


--ron


--ron
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 convert time (38:30) to decimal (38.5) format? Lori Excel Worksheet Functions 4 November 9th 05 05:00 AM
cell custom format mark kubicki Excel Worksheet Functions 1 August 25th 05 02:59 AM
Numbers after decimal point excel to word mail merge Andy P Excel Worksheet Functions 1 March 15th 05 11:48 AM
Change decimal format of cells depending on conditions? Cornelius Excel Worksheet Functions 1 February 25th 05 12:57 AM
decimal point override does not work Sam Brauen Excel Discussion (Misc queries) 0 January 6th 05 05:29 PM


All times are GMT +1. The time now is 10:33 AM.

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"