NT01
NT01

Reputation: 103

Excel VBA code for replacing all "." by "," in a column

I would like to have an excel VBA macro in order to replace all "." (dot) by "," (comma) in a column in one sheet.

When I try to do it with the following code, it replaces only if the cell value is ".". But does not replace "." inside cell value (i.e : 1.16 should be turned to 1,16 in column D inside sheet5)

Sub ReplaceDoTwComma()

Worksheets("Sheet5").Columns("D").Replace _
What:=".", Replacement:=",", _
SearchOrder:=xlByColumns, MatchCase:=True

End Sub

Can someone give me the good code to do this?

Thanks in advance...

Upvotes: 0

Views: 15357

Answers (2)

cheezsteak
cheezsteak

Reputation: 2917

Add the LookAt:=xlPart option.

    Worksheets("Sheet5").Columns("D").Replace _
        What:=sought, replacement:=replaced, LookAt:=xlPart

Upvotes: 1

AlexV
AlexV

Reputation: 11

you don't need a macro for this, just select the column in question in excel > Crtl + h and in find what put "." and in replace with put "," and hit replace all

Upvotes: 0

Related Questions