【发布时间】:2018-06-13 20:47:12
【问题描述】:
我正在编写一个允许我每月更新数据的宏。但是,我意识到,有时我需要在对数据进行更正时覆盖同一个月的数据。我正在尝试提出一个宏,它允许我搜索整个列,如果与数据匹配,允许我运行另一个宏以用新数据覆盖旧数据。关于如何解决这个问题的任何想法?
这是我目前所拥有的。我需要将整个列替换为 i 到 500。
Sub FindMatchingValue()
Dim i As Integer, ValueToFind As Integer
intValueToFind = Sheet8.Range("L6")
For i = 1 To 500 ' This needs to be the entire column
If Cells(i, 1).Value = intValueToFind Then
MsgBox ("Found value on row " & i)
Exit Sub
End If
Next i
MsgBox ("Value not found in the range!")
End Sub
【问题讨论】:
-
录制宏,然后在完成上述操作后查看您拥有的代码。
-
我有代码的框架。我遇到的唯一问题是能够搜索整个列并将这些日期与另一张纸上的日期匹配。
-
如果您有代码,请将其发布在您的问题中,突出显示哪个位不起作用。
-
对不起