简体   繁体   中英

Excel vba replace comma with

I want to use this vba code in my sheet to replace any commas in column D with a full stop:

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

I had it working I'm sure for a minute but then it didn't! Any ideas???

You said in a comment that you put the code in Worksheet_SelectionChange . Put the code in a module instead, then run it when you want to use it. Then it will work for any sheet.

您已经替换了所有逗号,它将不再起作用。

Private Sub Worksheet_SelectionChange(ByVal Target As Range)

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

End Sub

It does work like this. Do not add the "_"

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM