carlijn997
New Member
- Joined
- Aug 9, 2022
- Messages
- 3
- Office Version
- 2019
- Platform
- Windows
Hi!
I'm very new with VBA so I mostly use the 'record macro' function, to then learn from the code and combine pieces I want for a macro.
I am European so we use a comma for decimals and not dots. Many, but not all files I work with have dots though, and my European version of Excel cannot calculate with them, since it does not recognise it as a number, but as text. I normally can fix this very easily by using "replace all", replacing all dots with comma's. When I record this in a macro, it works normally, but when i try to use that recorded macro, it just deletes the dot completely, leaving me with the numbers without a comma or a dot (e.g. "1.23456" becomes "123456" and not "1,23456" like I want). It does it to all numbers, regardless of how many decimals it has, so just deviding every number is also not an option. Any idea why this happens and how I can fix it or a different code I can use to do what I am trying to do? I need to repeat this very often, together with some simple calculations, hence me trying to make a macro. Thanks!
I'm very new with VBA so I mostly use the 'record macro' function, to then learn from the code and combine pieces I want for a macro.
I am European so we use a comma for decimals and not dots. Many, but not all files I work with have dots though, and my European version of Excel cannot calculate with them, since it does not recognise it as a number, but as text. I normally can fix this very easily by using "replace all", replacing all dots with comma's. When I record this in a macro, it works normally, but when i try to use that recorded macro, it just deletes the dot completely, leaving me with the numbers without a comma or a dot (e.g. "1.23456" becomes "123456" and not "1,23456" like I want). It does it to all numbers, regardless of how many decimals it has, so just deviding every number is also not an option. Any idea why this happens and how I can fix it or a different code I can use to do what I am trying to do? I need to repeat this very often, together with some simple calculations, hence me trying to make a macro. Thanks!
VBA Code:
Sub Macro1()
Cells.Replace What:=".", Replacement:=",", LookAt:=xlPart, SearchOrder _
:=xlByRows
End Sub