我有一些宏,如:
Columns("F:M").Select
Selection.Replace What:=",", Replacement:="", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=True, SearchFormat:=False, _
ReplaceFormat:=False
但我想将当前日期(甚至只是一串文本)放入发生替换的行的单元格 A 中。
最佳答案
我想您需要将替换更改为查找和替换。就像是:
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
关于Excel VBA selection.replace 并且如果被替换,则将文本放在被替换行的 a 列中,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/5026423/