Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
RWN RWN is offline
external usenet poster
 
Posts: 104
Default Concatented Numbers Display as Scientific Notation

xl2k on w2kPro.
My macro is creating a "Key" field that is made up of a concatenation of two cells.
The first cell is seven digits, the second varies between 2 and seven digits.
The cells are on a CSV workbook.

I insert the Key column and create the Key with;

"SrcSht.Cells(i, 1) = SrcSht.Cells(i, 2) & SrcSht.Cells(i, 3)"

The resultant display will vary as follows;
Key Field 1 Field 2
1E+11 1000001 29830
1000002309 1000002 309


The reasoning behind this is beyond me although, for this app, it doesn't matter as a
lookup has no problem finding the key and the "=" entry area displays the correct value.
Also, if I do the concatenation using the UI (Field1 & Field2) all is well.
Some results (not all) will come out correctly if I enlarge the column width.

Therefore it appears to be a display anomaly only(?).

--
Regards;
Rob
------------------------------------------------------------------------






  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 162
Default Concatented Numbers Display as Scientific Notation

If the cell is formatted as General (the default) then it will
automatically display as scientific notation if the column is too
narrow. It will revert to normal notation if the column is autosized.
If the column is formatted to Number and the column is too narrow, the
Excel will fill the cell with ####. Again, the number will look normal
when the column width is widened enough.

So if you want the display to look correct, have your macro do a
Columns("A:A").EntireColumn.AutoFit statement after concatenating all
the values.

  #3   Report Post  
Posted to microsoft.public.excel.programming
RWN RWN is offline
external usenet poster
 
Posts: 104
Default Concatented Numbers Display as Scientific Notation

Nick;
Thanks.
I thought that what was the case given that the format is General but, as I mentioned,
only some results will come out correctly if I enlarge the column width.
I tried enlarging the column width both in the UI and the macro (Autofilt).

Looking at it again it seems that if the second field is longer than four digits it won't
display properly.
i.e. if the concatenated length is 11 digits it screws up.

As noted, the actual value is ok, just the display is "wonky".

I think I'm missing something fundamental here (or a few brain cells).
--
Regards;
Rob
------------------------------------------------------------------------
"Nick Hebb" wrote in message
oups.com...
If the cell is formatted as General (the default) then it will
automatically display as scientific notation if the column is too
narrow. It will revert to normal notation if the column is autosized.
If the column is formatted to Number and the column is too narrow, the
Excel will fill the cell with ####. Again, the number will look normal
when the column width is widened enough.

So if you want the display to look correct, have your macro do a
Columns("A:A").EntireColumn.AutoFit statement after concatenating all
the values.



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,758
Default Concatented Numbers Display as Scientific Notation

You could give that cell a nice number format and not have to worry about what
excel likes to do:

with SrcSht.Cells(i, 1)
.value = SrcSht.Cells(i, 2).value & SrcSht.Cells(i, 3).value
.numberformat= "0"
.entirecolumn.autofit 'stop #'s from showing up.
end with

RWN wrote:

Nick;
Thanks.
I thought that what was the case given that the format is General but, as I mentioned,
only some results will come out correctly if I enlarge the column width.
I tried enlarging the column width both in the UI and the macro (Autofilt).

Looking at it again it seems that if the second field is longer than four digits it won't
display properly.
i.e. if the concatenated length is 11 digits it screws up.

As noted, the actual value is ok, just the display is "wonky".

I think I'm missing something fundamental here (or a few brain cells).
--
Regards;
Rob
------------------------------------------------------------------------
"Nick Hebb" wrote in message
oups.com...
If the cell is formatted as General (the default) then it will
automatically display as scientific notation if the column is too
narrow. It will revert to normal notation if the column is autosized.
If the column is formatted to Number and the column is too narrow, the
Excel will fill the cell with ####. Again, the number will look normal
when the column width is widened enough.

So if you want the display to look correct, have your macro do a
Columns("A:A").EntireColumn.AutoFit statement after concatenating all
the values.


--

Dave Peterson
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 162
Default Concatented Numbers Display as Scientific Notation

Rob, are you doing Autofit and Number cell formatting, or just Autofit?
I tried this out and saw the issue with numbers greater than 11
digits. Like you said, changing the width didn't help. But changing
the format to Number (with 0 decimal places) did.

Playing around a bit, I also found that numbers 1E16 have truncated
precision, so you may want to watch out for that if you're
concatenating very large numbers



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,758
Default Concatented Numbers Display as Scientific Notation

And if Rob doesn't need the value as a number, he could make it text:

with SrcSht.Cells(i, 1)
.value = "'" & SrcSht.Cells(i, 2).value & SrcSht.Cells(i, 3).value
.entirecolumn.autofit
end with

or

with SrcSht.Cells(i, 1)
.numberformat= "@"
.value = SrcSht.Cells(i, 2).value & SrcSht.Cells(i, 3).value
.entirecolumn.autofit
end with

Nick Hebb wrote:

Rob, are you doing Autofit and Number cell formatting, or just Autofit?
I tried this out and saw the issue with numbers greater than 11
digits. Like you said, changing the width didn't help. But changing
the format to Number (with 0 decimal places) did.

Playing around a bit, I also found that numbers 1E16 have truncated
precision, so you may want to watch out for that if you're
concatenating very large numbers


--

Dave Peterson
  #7   Report Post  
Posted to microsoft.public.excel.programming
RWN RWN is offline
external usenet poster
 
Posts: 104
Default Concatented Numbers Display as Scientific Notation

Nick;
Thanks.
As I noted in my response to Dave, this was the 1st time I'd seen this and was wondering
If I'd "slipped a cog" somewhere.

Also, I believe the max # is 1E14 (15 digit number) which doesn't concern me because my
Key will never exceed 14 digits, but thanks for the reminder.

--
Regards;
Rob
------------------------------------------------------------------------
"Nick Hebb" wrote in message
ups.com...
Rob, are you doing Autofit and Number cell formatting, or just Autofit?
I tried this out and saw the issue with numbers greater than 11
digits. Like you said, changing the width didn't help. But changing
the format to Number (with 0 decimal places) did.

Playing around a bit, I also found that numbers 1E16 have truncated
precision, so you may want to watch out for that if you're
concatenating very large numbers



  #8   Report Post  
Posted to microsoft.public.excel.programming
RWN RWN is offline
external usenet poster
 
Posts: 104
Default Concatented Numbers Display as Scientific Notation

Dave;
That's basically what I wound up doing.
I guess my question was more in the realm of "What's this?".
I'd never seen this before-mind you, there's a lot of things I haven't seen!.
(Just when I thought I knew what I was doing:-o)
--
Regards;
Rob
------------------------------------------------------------------------
"Dave Peterson" wrote in message
...
You could give that cell a nice number format and not have to worry about what
excel likes to do:

with SrcSht.Cells(i, 1)
.value = SrcSht.Cells(i, 2).value & SrcSht.Cells(i, 3).value
.numberformat= "0"
.entirecolumn.autofit 'stop #'s from showing up.
end with

RWN wrote:

Nick;
Thanks.
I thought that what was the case given that the format is General but, as I mentioned,
only some results will come out correctly if I enlarge the column width.
I tried enlarging the column width both in the UI and the macro (Autofilt).

Looking at it again it seems that if the second field is longer than four digits it

won't
display properly.
i.e. if the concatenated length is 11 digits it screws up.

As noted, the actual value is ok, just the display is "wonky".

I think I'm missing something fundamental here (or a few brain cells).
--
Regards;
Rob
------------------------------------------------------------------------
"Nick Hebb" wrote in message
oups.com...
If the cell is formatted as General (the default) then it will
automatically display as scientific notation if the column is too
narrow. It will revert to normal notation if the column is autosized.
If the column is formatted to Number and the column is too narrow, the
Excel will fill the cell with ####. Again, the number will look normal
when the column width is widened enough.

So if you want the display to look correct, have your macro do a
Columns("A:A").EntireColumn.AutoFit statement after concatenating all
the values.


--

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
Can Excel display in scientific notation with a 3digit exponent? kentk Excel Discussion (Misc queries) 1 February 11th 09 04:25 PM
large numbers as text replaced with scientific notation [email protected] Excel Discussion (Misc queries) 2 January 12th 09 11:33 PM
Hex numbers displayed in scientific notation when importing text f Gabriel Nehmer Excel Discussion (Misc queries) 2 July 20th 07 04:08 PM
scientific notation to display 1.8 x 10-5 in Excel feloniousmoney New Users to Excel 1 July 6th 05 10:31 PM
Long numbers show up as Scientific Notation berryware421243 Excel Discussion (Misc queries) 5 February 8th 05 03:21 AM


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