Find and Replace decimal point for comma

geofspa

New Member
Joined
Jan 7, 2012
Messages
30
Office Version
  1. 365
Platform
  1. Windows
Hi Guys

I have 3 columns in Excel 2007 and in Text format containing text numbers in the form of 9.10. I can complete a "find and replace" operation finding "." and replacing with ",". some of these number run to three decimal places "9.153" and when the decimal point is replaced in this type number I have returned "9153" omitting the "," altogether. Why might this be and is there any way I can fix it?

Please note if the found number is 91.53 then after the replace I get 91,53
 

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off
I have 3 columns in Excel 2007 and in Text format containing text numbers in the form of 9.10. I can complete a "find and replace" operation finding "." and replacing with ",". some of these number run to three decimal places "9.153" and when the decimal point is replaced in this type number I have returned "9153" omitting the "," altogether. Why might this be and is there any way I can fix it?

Please note if the found number is 91.53 then after the replace I get 91,53

What is your locale's natural decimal point... a dot or a comma?
 
Upvote 0
Hi Rick

Normally decimal point is the full stop . but I need to change this for uploading to a comma , . All cells on this sheet are formatted as TEXT cells.
 
Upvote 0
Hi Guys

I have 3 columns in Excel 2007 and in Text format containing text numbers in the form of 9.10. I can complete a "find and replace" operation finding "." and replacing with ",". some of these number run to three decimal places "9.153" and when the decimal point is replaced in this type number I have returned "9153" omitting the "," altogether. Why might this be and is there any way I can fix it?

Please note if the found number is 91.53 then after the replace I get 91,53

Care to post some mpre examples?
 
Upvote 0
Hi Rick

Normally decimal point is the full stop . but I need to change this for uploading to a comma , . All cells on this sheet are formatted as TEXT cells.

It looks like during the replacement part of its operation, Excel ignores the formatting of the cell the value came from so when it substitutes the comma, it sees 9,153 and recognizes that as a number with a thousand's separator, and place the numerical value (9153) back into the Text formatted cell. I cannot think of a non-VBA way to stop it from doing that. The VBA way to get around it is to select the cells with these values in them (you can select the whole column if you want as long as no cells in the selection contain dots that are not to be converted) and run this macro...

Code:
Sub ConvertDotToComma()
  Selection = Evaluate(Replace("IF(ISNUMBER(FIND(""."",@)),SUBSTITUTE(@,""."","",""),@)", "@", Selection.Address))
End Sub

HOW TO INSTALL MACROs
------------------------------------
If you are new to macros, they are easy to install and use. To install it, simply press ALT+F11 to go into the VB editor and, once there, click Insert/Module on its menu bar, then copy/paste the above code into the code window that just opened up. That's it.... you are done. To use the macro, go back to the worksheet with your data on it and press ALT+F8, select the macro name (MoveStatesUpOneRowInColumnF) from the list that appears and click the Run button. The macro will execute and perform the action(s) you asked for. Since this appears to be a once only need for any given worksheet, you can now delete the macro's code. On the other hand, if you will need to do this within this same workbook at future dates, then if you are using XL2007 or above, make sure you save your file as an "Excel Macro-Enabled Workbook (*.xlsm) and answer the "do you want to enable macros" question as "yes" or "OK" (depending on the button label for your version of Excel) the next time you open your workbook.
 
Upvote 0
It looks like during the replacement part of its operation, Excel ignores the formatting of the cell the value came from so when it substitutes the comma, it sees 9,153 and recognizes that as a number with a thousand's separator, and place the numerical value (9153) back into the Text formatted cell. I cannot think of a non-VBA way to stop it from doing that. The VBA way to get around it is to select the cells with these values in them (you can select the whole column if you want as long as no cells in the selection contain dots that are not to be converted) and run this macro...

Code:
Sub ConvertDotToComma()
  Selection = Evaluate(Replace("IF(ISNUMBER(FIND(""."",@)),SUBSTITUTE(@,""."","",""),@)", "@", Selection.Address))
End Sub

HOW TO INSTALL MACROs
------------------------------------
If you are new to macros, they are easy to install and use. To install it, simply press ALT+F11 to go into the VB editor and, once there, click Insert/Module on its menu bar, then copy/paste the above code into the code window that just opened up. That's it.... you are done. To use the macro, go back to the worksheet with your data on it and press ALT+F8, select the macro name (MoveStatesUpOneRowInColumnF) from the list that appears and click the Run button. The macro will execute and perform the action(s) you asked for. Since this appears to be a once only need for any given worksheet, you can now delete the macro's code. On the other hand, if you will need to do this within this same workbook at future dates, then if you are using XL2007 or above, make sure you save your file as an "Excel Macro-Enabled Workbook (*.xlsm) and answer the "do you want to enable macros" question as "yes" or "OK" (depending on the button label for your version of Excel) the next time you open your workbook.

Many thanks for your promt reply - I will take your advice and learn some more about macros and spreadsheets:)
 
Upvote 0

Forum statistics

Threads
1,223,275
Messages
6,171,127
Members
452,381
Latest member
Nova88

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