Auto-Convert Decimal Numbers to Specific Cells

Disarmonious

Board Regular
Joined
Oct 31, 2016
Messages
144
Hello,

I’m trying to figure out how to customize specific cells to add 2 decimal places when typing a number. For instance, I would like all numbers within cell range B2:B20 to add two decimal points when typing a number. E.g. – In cell B2, if I enter 1234, I want that cell to display 12.34. In cell B3, I enter 23873, I would like that cell to convert this number to 238.73, etc. Keep in mind that I only want dedicated cells to automatically convert two decimal places and not the entire worksheet.
 

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.
I’m trying to figure out how to customize specific cells to add 2 decimal places when typing a number. For instance, I would like all numbers within cell range B2:B20 to add two decimal points when typing a number. E.g. – In cell B2, if I enter 1234, I want that cell to display 12.34. In cell B3, I enter 23873, I would like that cell to convert this number to 238.73, etc. Keep in mind that I only want dedicated cells to automatically convert two decimal places and not the entire worksheet.
Do you want the underlying values in the cell to physically change (type 1234 and have the value actually be 12.34) or simply display with two decimal places but still remain what the user typed originally (user types 1234, cell displays 12.34 but Formula Bar still shows 1234)?
 
Upvote 0
Hello Rick,

Yeah, I want the values to change from 1234 to 12.34, if 1234 is typed in the specified cell. I think my discovery of custom formatting those cells to "00\.00" worked for me. I'm going to keep testing these cells, and if this doesn't work out for me, then I'll need further assistance on this topic. In the meantime, if there are other ways for me to get these results, your suggestions would be greatly appreciated. Thank you for your time.
 
Upvote 0
You could use a change event macro like this:
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim R As Range, c As Range
Application.ScreenUpdating = False
Set R = Me.Range("B2:B20")   'set the range to monitor here
If Not Intersect(Target, R) Is Nothing Then
    Application.EnableEvents = False
    For Each c In Intersect(Target, R)
        If IsNumeric(c.Value) Then c.Value = c.Value / 100
    Next c
    Application.EnableEvents = True
End If
Application.ScreenUpdating = True
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

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