【发布时间】:2014-12-21 13:49:16
【问题描述】:
我是 VBA 编码的新手,我想复制同一行中的单元格以获得我搜索过的值。
当我厌倦了访问时,我遇到了错误。例如,我想在我的 xl 表中找到“abcd”。 假设在单元格 c12 中找到“abcd”,我想复制单元格 E12、F12 中的值。
我在尝试使用偏移属性时遇到错误。
Private Sub FindingValues()
Dim val As Variant
val = InputBox(" Please Enter the value you want to search for")
Set c = Cells.Find(val, LookIn:=xlValues, MatchCase:=False)
If Not c Is Nothing Then
firstaddress = c.Address
Do
MsgBox "Value of val is found at " & c.Address
Set c = Cells.FindNext(c)
Loop While Not c Is Nothing And c.Address <> firstaddress
End If
End Sub
在上面的代码中,我可以得到我搜索过的单元格的地址。我想找到行单元格值旁边的值。 就像我们说在单元格 c12 中找到“abcd”一样,我想在 d12、e12 中找到值..
【问题讨论】: