Iris
I see a few sub-problems here.
1) You want the number converted from General Format to Fixed (2
decimal places). The issue is that if you tell Excel to display 12 as
12.00, when you convert it to text it reverts back to 12. So, problem
two then becomes
2) Determine length of string
3) Determine position of decimal point
4) Calculate number of characters in string between decimal point
and end of string.
If decimal point not present, add ".00" with concatenate
If number = 0, add "00" 'I know this case does not exist.
If number = 1, add "0" with concatenate
5) Then you want to add the letter T to the end. You can use
concatenate for this.
Easy enough to do all this in Excel, and if you record your work with
the macro recorder (using fixed and relative references as appropriate)
you will get a good starting point for your code.
Paul
From: ExcelVBA@yahoogroups.com [mailto:ExcelVBA@yahoogroups.com] On
Behalf Of Iris
Sent: Thursday, 8 December 2011 3:41 PM
To: ExcelVBA@yahoogroups.com
Subject: [ExcelVBA] Decimal number convert to string
How to write a VBA code to convert decimal number to string
example:
Number String
12 12.00T
12.5 12.50T
12.55 12.55T
Thanks in advance!
[Non-text portions of this message have been removed]
Be sure to check out TechTrax Ezine for many, free Excel VBA articles! Go here: http://www.mousetrax.com/techtrax to enter the ezine, then search the ARCHIVES for EXCEL VBA.
----------------------------------
Visit our ExcelVBA group home page for more info and support files:
http://groups.yahoo.com/group/ExcelVBA
----------------------------------
More free tutorials and resources available at:
http://www.mousetrax.com
----------------------------------
Tidak ada komentar:
Posting Komentar