Number format

Mustakrakish

New Member
Joined
Nov 7, 2011
Messages
5
Hi everybody,

I have problem with changing number format.
When I export data from SAP, number format is like this: 10.548,45
In excel, this is stored as a text, cause of that dot as a thousands divider. Usualy i do just replace dot with nothing and it works. but when i do it as a macro, for some reason, it replaces comma as well, therefore instead of having number 10 548,45 I end up with 1 054 845.

This is my code for replacing dots.

Columns("D:F").Select
Selection.Replace What:=".", Replacement:="", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False

Cell format is number.

Thank you very much
 

Excel Facts

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.
Eh, i should have wrote some question right? :biggrin:

So is there a macro that will take out those dots and converts text numbers to normal numbers?

Thanks :P
 
Upvote 0
Which version of excel are you using?

This shows how to do what you want, it works in 2003, but not in 2007 (no reference to 2010 so don't know what will happen there).

http://www.howtogeek.com/howto/microsoft-office/import-text-into-excel-2007/

You could use something like

Code:
Sub Convert_Decimal()
With Columns("D:F")
    .Replace What:=",", Replacement:="|", LookAt:=xlPart
    .Replace What:=".", Replacement:="", LookAt:=xlPart
    .Replace What:="|", Replacement:=".", LookAt:=xlPart
End With
End Sub

Which should be used with caution! Running it twice will cause the same problem as your recorded code.
 
Last edited:
Upvote 0
This seems to work with me

Code:
With Range("D:F")
    .Replace ".", ""
    .Replace ",", "."
End With

UK regional settings and excel 2007
 
Upvote 0
This seems to work with me

Code:
With Range("D:F")
    .Replace ".", ""
    .Replace ",", "."
End With

UK regional settings and excel 2007

Graeme,

I could be wrong but think that the OP's regional settings, or cell formats might be playing a part in the problem :confused:

The first line of your code does the same as their recorded code, which they said removed the comma as well, which, thoeretically, would leave nothing for the second line to replace.

Would be so much easier if excel had a simple format conversion tool for region specific values. :rolleyes:
 
Upvote 0
I am using 2007 and 2010.

Source file is not text doc, it is normal .xls (2007) file from SAP export.

Thx guys I tried to use your solutions, but somehow comma is still replaced by nothing therefore my numbers are completley messed up :(

I am confused with the difference between using replace in excel and using it as a macro. I have this problem only when I use it as a macro :(
 
Upvote 0

Forum statistics

Threads
1,214,641
Messages
6,120,692
Members
448,979
Latest member
DET4492

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