custom number formatting

lezawang

Well-known Member
Joined
Mar 27, 2016
Messages
1,805
Office Version
  1. 2016
Platform
  1. Windows
Hi
I want to write a code to format numbers like the following

numberappears in excel
12001,2 K
15991,599 k

<tbody>
</tbody>

I found this code #,##0,
but did work as expected. Thank you very much.
 

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.
Try custom formatting using: #,##0 k

This will not remove the zero's, however.
 
Last edited:
Upvote 0
mumps,

I think they are using a system where a decimal point represented by a comma, not a period.
Hence, 1,2 K represents one-thousand two-hundred and 1,599 K represents one-thousand, five hundred, and ninety-nine.
So the "K" is just short-hand for "thousand".

lezawang,
Is that correct?
Are you regional settings in Excel already set up to use a comma instead of a period to indicate decimals?
 
Upvote 0
Joe4: Thank you for that.

This formula might work: =A1/1000 & " k"
 
Upvote 0
Thank you all. Yes that is right. The problem with this code #,##0 k
when I type 300, I will get 300 K, and when I type 3 I get 3 k
What I want to do is when I type
3 I get 3
and when I type 1000, i get 1k
and when I type 1500, I get 1,5 K

is that possible? Thank you all again.
mumps,

I think they are using a system where a decimal point represented by a comma, not a period.
Hence, 1,2 K represents one-thousand two-hundred and 1,599 K represents one-thousand, five hundred, and ninety-nine.
So the "K" is just short-hand for "thousand".

lezawang,
Is that correct?
Are you regional settings in Excel already set up to use a comma instead of a period to indicate decimals?
 
Upvote 0
Assuming you will be entering data in column A, place this macro in the code module for the worksheet (not a standard module).

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    If Intersect(Target, Range("A:A")) Is Nothing Then Exit Sub
    Application.EnableEvents = False
    If Len(Target) > 3 Then
        Target = Target / 1000 & " K"
    End If
    Application.EnableEvents = True
End Sub
 
Upvote 0
Hi
I want to write a code to format numbers like the following

numberappears in excel
12001,2 K
15991,599 k

<tbody>
</tbody>

I found this code #,##0,
but did work as expected. Thank you very much.
I am using a system where a dot is my decimal point. What I don't know on your system is whether you use a dot or a comma for the decimal point when you do a Custom Format. Assuming you use a comma (meaning the dot is your thousands separator), try using this custom format...

0,0#######. K
 
Upvote 0

Forum statistics

Threads
1,215,008
Messages
6,122,672
Members
449,091
Latest member
peppernaut

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top