to bring abbreviation B for billion and T for trillion

abdulncr

New Member
Joined
Aug 14, 2012
Messages
27
Hi friends,

I have value in trillion and million in a column and make it to the chart. the follow code pasted in the format cell custom- working fine for million and billion. Please help me how do i get it work for trillion too.
[>999999999.999]#.0,,, _-"B";[>999999.999]#.0,, "M";#,##0 _M

Regards
Abdul
 

abdulncr

New Member
Joined
Aug 14, 2012
Messages
27
Hi,

Just add : #,,,," T"

HTH
HI,

Thanks for the answer, i added as you told. now become my custom format as below. still not working. could you please look into
[>999999999.999]#.0,,, _-"B";[>999999.999]#.0,, "M";##,#0 _M#,,,," T"

Regards
Abdul
 

HelenTherese

New Member
Joined
Mar 20, 2013
Messages
1
I'm assuming that it's because you have the Trillion at the end and therefore anything over 999999999.999 is coming up as B?

Do you need to put

[>999999999999.999]#.0,,, _-"T";

at the beginning?
 

abdulncr

New Member
Joined
Aug 14, 2012
Messages
27
I'm assuming that it's because you have the Trillion at the end and therefore anything over 999999999.999 is coming up as B?

Do you need to put

[>999999999999.999]#.0,,, _-"T";

at the beginning?
Hi,
Thank u so much for the update. but when i add first i am getting message " microsoft excel cant use number format you typed". when i make only two condition for the T and B it is working fine. so am i right in assuming more than two condition is not accepting in the format. is there any way to accept more than two condition.
Regards
Abdul
 

Rick Rothstein

MrExcel MVP
Joined
Apr 18, 2011
Messages
35,504
Office Version
2010
Platform
Windows
Sorry, you can't have more than 3 conditions.
But you can "fake" it by using VB event code...
Rich (BB code):
Private Sub Worksheet_Change(ByVal Target As Range)
  If Not Intersect(Target, Range("C:C")) Is Nothing Then
    If Target.Value < 1000000 Then
      Target.NumberFormat = "#,##0 _M"
    ElseIf Target.Value < 1000000000 Then
      Target.NumberFormat = "#.0,, ""M"""
    ElseIf Target.Value < 1000000000000# Then
      Target.NumberFormat = "#.0,,, _-""B"""
    Else
      Target.NumberFormat = "#.0,,,, _-""T"""
    End If
  End If
End Sub
NOTE: The above code is set to monitor Column C... change what I have highlighted in red to the letter designation for the actual column range you want to monitor.

HOW TO INSTALL Event Code
------------------------------------
If you are new to event code procedures, they are easy to install. To install it, right-click the name tab at the bottom of the worksheet that is to have the functionality to be provided by the event code and select "View Code" from the popup menu that appears. This will open up the code window for that worksheet. Copy/Paste the event code into that code window. That's it... the code will now operate automatically when its particular event procedure is raised by an action you take on the worksheet itself.
 

abdulncr

New Member
Joined
Aug 14, 2012
Messages
27
But you can "fake" it by using VB event code...
Rich (BB code):
Private Sub Worksheet_Change(ByVal Target As Range)
  If Not Intersect(Target, Range("C:C")) Is Nothing Then
    If Target.Value < 1000000 Then
      Target.NumberFormat = "#,##0 _M"
    ElseIf Target.Value < 1000000000 Then
      Target.NumberFormat = "#.0,, ""M"""
    ElseIf Target.Value < 1000000000000# Then
      Target.NumberFormat = "#.0,,, _-""B"""
    Else
      Target.NumberFormat = "#.0,,,, _-""T"""
    End If
  End If
End Sub
NOTE: The above code is set to monitor Column C... change what I have highlighted in red to the letter designation for the actual column range you want to monitor.

HOW TO INSTALL Event Code
------------------------------------
If you are new to event code procedures, they are easy to install. To install it, right-click the name tab at the bottom of the worksheet that is to have the functionality to be provided by the event code and select "View Code" from the popup menu that appears. This will open up the code window for that worksheet. Copy/Paste the event code into that code window. That's it... the code will now operate automatically when its particular event procedure is raised by an action you take on the worksheet itself.
it is working fine. thank you so much for your help.
 

Forum statistics

Threads
1,081,657
Messages
5,360,291
Members
400,580
Latest member
Drexl88

Some videos you may like

This Week's Hot Topics

  • VBA (Userform)
    Hi All, I just would like to know why my code isn't working. Here is my VBA code: [CODE=vba]Private Sub OKButton_Click() Dim i As Integer...
  • List box that changes fill color
    Hello, I have gone through so many pages trying to figure this out. I have a 2020 calendar that depending on the day needs to have a certain...
  • Remove duplicates and retain one. Cross-linked cases
    Hi all I ran out of google keywords to use and still couldn't find a reference how to achieve the results of a single count. It would be great if...
  • VBA Copy and Paste With Duplicates
    Hello All, I'm in need of some input. My VBA skills are sub-par at best. I've assembled this code from basic research and it works but is...
  • Macro
    is it possible for a macro to run if the active cell value is different to the value above it
  • IF DATE and TIME
    I currently use this to check if date has passed but i also need to set a time on it too. Is it possible? [CODE=vba]=IF(B:B>TODAY(),"Not...
Top