gpt4 book ai didi

Excel VBA 选择.替换,如果替换,则将文本放在替换行的 a 列中

转载 作者:行者123 更新时间:2023-12-02 10:57:51 25 4
gpt4 key购买 nike

我有一些宏,例如:

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 选择.替换,如果替换,则将文本放在替换行的 a 列中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5026423/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com