kekn
09-10-2010, 12:31 PM
Hi
I'm new to VBA and new to these forums. I registered here in hope of some help with my (at the moment) very simple code.
So, I have Excel 2010 (think the problem applies for 2007 as well, though). The thing is, Excel uses commas instead of dots... at least here in Denmark. And I have a LOT of data, going like this:
583.74
582.7
582.81
581
574.04
587.73
573.01
...
So I made a macro that could do the replacing for me... simple enough. Here is the code on a small area:
Sub Makro1()
Range("A1:A6").Select
Selection.Replace What:=".", Replacement:=",", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
End Sub
It makes the replacement alright, but apparently still recognize it as text. Selecting a numbers format doesn't help, but pressing F2 and enter solves it :wot (also, there's an error showing up next to the cells saying that the number is formatted as text... pressing "convert to number" solves it too)
Here's a simple made sheet that shows the process... try running the macro and behold:
EDIT: Ok, I can't post links yet... gotta play by the rules, right? :)
Help a newbie do this small thing :banghead:
/kekn
I'm new to VBA and new to these forums. I registered here in hope of some help with my (at the moment) very simple code.
So, I have Excel 2010 (think the problem applies for 2007 as well, though). The thing is, Excel uses commas instead of dots... at least here in Denmark. And I have a LOT of data, going like this:
583.74
582.7
582.81
581
574.04
587.73
573.01
...
So I made a macro that could do the replacing for me... simple enough. Here is the code on a small area:
Sub Makro1()
Range("A1:A6").Select
Selection.Replace What:=".", Replacement:=",", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
End Sub
It makes the replacement alright, but apparently still recognize it as text. Selecting a numbers format doesn't help, but pressing F2 and enter solves it :wot (also, there's an error showing up next to the cells saying that the number is formatted as text... pressing "convert to number" solves it too)
Here's a simple made sheet that shows the process... try running the macro and behold:
EDIT: Ok, I can't post links yet... gotta play by the rules, right? :)
Help a newbie do this small thing :banghead:
/kekn