The code below changes comma to period for Column D. I want it happen for both D & G.
Option Explicit
Sub ReplaceDoTwComma()
Worksheets("Sheet1").Columns("D").replace _
What:=",", replacement:=".", LookAt:=xlPart
End Sub
I have tried
Worksheets("Sheet1").Columns("D").replace _
Worksheets("Sheet1").Columns("G").replace _
or Columns("D", "G")
or Columns ("D" & "G")
But no luck.
My good reference is Excel VBA code for replacing all "." by "," in a column
Any guidance would be highly appreciated. Thank you!
do two seperate calls, remember the _
indicates a line continuation so both lines need to be duplicated:
Option Explicit
Sub ReplaceDoTwComma()
Worksheets("Sheet1").Columns("D").replace _
What:=",", replacement:=".", LookAt:=xlPart
Worksheets("Sheet1").Columns("G").replace _
What:=",", replacement:=".", LookAt:=xlPart
End Sub
Or
Option Explicit
Sub ReplaceDoTwComma()
Worksheets("Sheet1").Range("D:D,G:G").replace _
What:=",", replacement:=".", LookAt:=xlPart
End Sub
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.