I'm having trouble understanding how to make a macro.
我很难理解如何做一个宏。
I'm trying to search down a column, and in each cell check for the text "TODAY()"
, and replace it with "TODAY() + B2"
where B2 is some number of days.
我正在搜索一个列,在每个单元格中检查文本“TODAY()”,将它替换为“TODAY() + B2”,其中B2是一些天数。
I've been searching and I think I'm close but I'm still having trouble.
我一直在寻找,我认为我很接近,但我仍然有麻烦。
Sub findrep()
Dim Findtext As String
Dim Replacetext As String
Findtext = "TODAY()"
Replacetext = SUM(TODAY(),"Sheets("Sheet1").Range("B2").Value")
Columns("A").Replace what:=Findtext, replacement:=Replacetext, lookat:=xlPart, MatchCase:=False
End Sub
I'm wanting to show the date in the cell sometime in the future depending on the number of days in cell B2. The VBA has to be able to search through the formula in the cell as there is more than just "TODAY()"
in the formula.
我想要在未来的某个时间,根据细胞B2的天数来显示细胞的日期。VBA必须能够搜索单元格中的公式,因为公式中不仅仅只有“TODAY()”。
Thanks in advance.
提前谢谢。
1 个解决方案
#1
5
Try to change this line
试着改变这条线
Replacetext = SUM(TODAY(),"Sheets("Sheet1").Range("B2").Value")
to
来
Replacetext = "TODAY()+Sheet1!B2"
#1
5
Try to change this line
试着改变这条线
Replacetext = SUM(TODAY(),"Sheets("Sheet1").Range("B2").Value")
to
来
Replacetext = "TODAY()+Sheet1!B2"