vba - How to make Excel doesn't truncate 0's in formatting decimal numbers? -
suppose have following random numbers in notepad:
1.19 0.040 10.1123 23.110 21.223 2.35456 4.0 10234.0009 456798.7500 123 34.560 40060 33.7876
if copy numbers above , paste them in excel, number formats change this
1.19 0.04 10.1123 23.11 21.223 2.35456 4 10234.0009 456798.75 123 34.56 40060 33.7876
i intend copy-paste numbers without changing original formats, examples:
0.040 keeps 0.040, not 0.04;
4.0 keeps 4.0, not 4;
- 456798.7500 keeps 456798.7500, not 456798.75; , on.
i'm aware can use conditional formattings like
if condition_1 cells(...).numberformat = "0.00" elseif condition_2 cells(...).numberformat = "0.000" ... else result_else end if
or use select ... case statement, problems these methods are:
- the code can lengthy , looks messy.
- if numbers change, conditionals must change, too.
so question is:
how make excel doesn't truncate 0's in end of decimal numbers?
p.s. want keep values numbers, not texts.
addendum: don't understand why 1 downvote op since kind of representation matter in financial data example: foreign exchange or currency rate.
if place original data in column a (with posted formats) , run this:
sub copyfull() dim range, b range set = range("a1:a13") set b = range("b1:b13") a.copy b end sub
the copied data items have same formats originals:
so if a9 has numberformat
of 0.0000, b9.
edit#1:
if data started out in open notepad process, would:
- manually (or programmatically) store data text file (.txt)
- import text file column text
- convert each item in column number
numberformat
consistent text format
Comments
Post a Comment