Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在尝试编写一个 VBA 代码以在单元格范围内查找特定字符串,在找到该字符串后,我需要在下面的单元格中写入一些内容。
例子
我在 raw 1 上有单词“Test”,所以我需要找到字符串在哪个单元格中,例如 F1,之后我需要自动填充下面的单元格,在这种情况下是 F2,带有单词“Ok”
提前致谢
卡洛斯
试试下面的代码:
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean) For i = 1 To Cells(1, 1).End(xlToRight).Column If InStr(Cells(1, i), "Test") Then Cells(2, i) = "OK" End If Next End Sub