Excel VBA selection.replace,如果被replace,把文本放在被replace的行的列a中

我有一些macros:

Columns("F:M").Select Selection.Replace What:=",", Replacement:="", LookAt:=xlPart, _ SearchOrder:=xlByRows, MatchCase:=True, SearchFormat:=False, _ ReplaceFormat:=False 

但是我想把当前date(甚至只是一串文本)放在发生replace的行的单元格A中。

我想你会需要改变你的replace为查找和replace。 就像是:

 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