且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Excel VBA selection.replace,如果已替换,则将文本放在替换行的a列中

更新时间:2023-02-18 09:23:58

我想您需要将您的替换项更改为查找并替换".像这样:

I imagine you will need to change your replace to a find and replace. Something like:

Dim c As Range
Columns("F:M").Select
Set c = Selection.Find(What:=",", LookAt:=xlPart, _
    SearchOrder:=xlByRows, MatchCase:=True, SearchFormat:=False)
If Not c Is Nothing Then
    Do
        c.Replace What:=",", Replacement:="", LookAt:=xlPart, _
            SearchOrder:=xlByRows, MatchCase:=True, SearchFormat:=False, _
            ReplaceFormat:=False
        Cells(c.Row, 1).Value = Date
        Set c = Selection.FindNext(c)
    Loop While Not c Is Nothing
End If