Replacing point with comma using VBA

Hello,

For those who know VBA Excel,

I created a very simple macro that selects a sheet and replaces periods with commas,

when we do it "manually" (Edit/Replace, etc.), it works perfectly.

However, with the macro, which indeed describes the action mentioned above, it doesn't work.

For example, for numbers like: 1.27365e+006
the macro transforms them into: 127365000000

Here is the macro, it is very simple:

Sub pv3()

Cells.Select
Application.CutCopyMode = False
Selection.NumberFormat = "General"
Selection.Replace What:=".", Replacement:=",", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False

End Sub

Thank you in advance for your response
Configuration: Windows XP Internet Explorer 6.0

6 answers

  • Votes
  • Date
  • Descending date
  1. The subject is surely closed, but for those who will need it:

    It is necessary to replace the dot with a dot in the macro. In my case:

    Selection.Replace What:=".", Replacement:=".", LookAt:=xlPart, _
    SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
    ReplaceFormat:=False
    1. Thank you!!!!!!!! It's been a really long time since I've been looking, and the answer isn't obvious... Thanks again for responding to this post, it really comes at the perfect time for me.
    2. Thank you, I hadn't found it yet...
    3. Thank you! Not easy to guess...
    4. Well, we can say thank you; I've been looking for this for 1000 years!!
    5. Thank you very much! I will try it out! :-)