以下代码将逗号更改为D列的句号。 我想要D& G.
Option Explicit
Sub ReplaceDoTwComma()
Worksheets("Sheet1").Columns("D").replace _
What:=",", replacement:=".", LookAt:=xlPart
End Sub
我试过了
Worksheets("Sheet1").Columns("D").replace _
Worksheets("Sheet1").Columns("G").replace _
或Columns("D", "G")
或Columns ("D" & "G")
但没有运气。
我的好参考是Excel VBA code for replacing all "." by "," in a column
任何指导都将受到高度赞赏。 谢谢!
答案 0 :(得分:2)
进行两次单独的调用,请记住_
表示一行继续,因此需要重复两行:
Option Explicit
Sub ReplaceDoTwComma()
Worksheets("Sheet1").Columns("D").replace _
What:=",", replacement:=".", LookAt:=xlPart
Worksheets("Sheet1").Columns("G").replace _
What:=",", replacement:=".", LookAt:=xlPart
End Sub
或者
Option Explicit
Sub ReplaceDoTwComma()
Worksheets("Sheet1").Range("D:D,G:G").replace _
What:=",", replacement:=".", LookAt:=xlPart
End Sub