在范围内查找单元格然后偏移生成错误VBA

时间:2015-12-13 09:04:31

标签: excel vba excel-vba

我需要在一个范围内找到预订#。然后将活动单元偏移到左侧。我已尝试过至少3种不同的在线资源,但我无法获得任何工作。

这是我到目前为止所拥有的。

Dim FindString As String

    FindString = Sheets("Sheet1").Range("I1").Value
With Worksheets(1).Range("H1:H7")
    Set C = .Find(FindString, LookIn:=xlValues)
    C.Activate
    ActiveCell.Offset(0,-1)
End With

简单地说代码使用I1的值并搜索(H1:H7)然后将一个单元格偏移到左侧,但我一直得到"预期="或"语法"错误。

1 个答案:

答案 0 :(得分:0)

尝试

If not C is nothing then
    C.Activate
    ActiveCell.Offset(0,-1).Activate
Else
    'Some code for not found
End If