Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 523
Default Representing numbers with K, M, G sufix using a macro

You'll have to reverse the order of those ifs...

2,000,000,000,000 mod 1E12 = 0 so result = 2T
2,000,000,000,000 mod 1E9 = 0 so result = 2000G
etc.

Sam

"BSc Chem Eng Rick" wrote:

Function NumSuffix(MyNum as Long) as String
Dim Result as String
if MyNum Mod 1E12 = 0 then Result = CStr(Mynum/1E12) & " T"
if MyNum Mod 1E9 = 0 then Result = CStr(Mynum/1E9) & " G"
if MyNum Mod 1E6 = 0 then Result = CStr(Mynum/1E6) & " M"
if MyNum Mod 1E3 = 0 then Result = CStr(Mynum/1E3) & " K"
NumSuffix = Result
End Function
--
If this helps, please click "Yes"
<<<<<<<<<<<<


"Farooq Sheri" wrote:

I need help with code to convert a number, for example 2000000, into 2 M or
2000000000 into 2 G etc.

Thanks.

Farooq

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
bar on chart isn't representing correctly rrupp Charts and Charting in Excel 2 February 4th 08 11:30 PM
Can I have words representing numbers in a formula? PeterM Excel Discussion (Misc queries) 4 August 7th 06 09:29 PM
how to convert whole numbers representing seconds to mm:ss Elvin Excel Worksheet Functions 2 March 6th 06 05:49 PM
Representing symbols in charts Symbols in Charts Charts and Charting in Excel 1 July 14th 05 09:21 PM
FORMULAS FOR ADDING LETTERS REPRESENTING NUMBERS koolone Excel Discussion (Misc queries) 1 April 8th 05 12:39 PM


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