根据找到的值将变量分配给另一个单元格

时间:2015-07-31 15:46:08

标签: excel vba

我使用find命令设置了一个等于值(“Outlt”)的变量。我想在A列的左边设置单元格的值,等于另一个名为“Outnode”的变量

我使用偏移尝试了几种不同的代码但是我一直收到错误。任何人都可以帮我分配“Outnode”到单元格左边的单元格,我会找到“Outlt”吗?我没有正确地将“Findout”设置到我找到“Outlt”这个单词的单元格中吗?谢谢。

Sub FindOffsetvalue ()
    Dim number As Integer
    Dim Findout As range
    Dim Outnode As range

    Sheets(1).Activate

    If Trim(number) <> "" Then
    With Sheets(1).range("B:B")
                Set Findout = .Find(What:="Outlt", After:=.Cells(.Cells.Count), _
                    LookIn:=xlValues, Lookat:=xlWhole, SearchOrder:=xlByRows, _
                    SearchDirection:=xlNext, MatchCase:=False, SearchFormat:=False)

                If Not Findout Is Nothing Then
                   Findout.Select
                Else
                    MsgBox "Nothing found"
                End If
    End With
    End If
End Sub

1 个答案:

答案 0 :(得分:3)

            If Not Findout Is Nothing Then
               Findout.Select
               Set Outnode = Findout.Offset(0, -1)
            Else
                MsgBox "Nothing found"
            End If
相关问题