DINESHKUMAR PALANISAMY
DINESHKUMAR PALANISAMY

Reputation: 159

vba code to find a specific value and copy value in subsequent cell in the column and paste in a new sheet

I have a excel sheet with some data. In Column A, it has set of data, my objective is to copy the cell value below the cell which contains its value as "Line".

Columns("B:B").Select
Set cell = Selection.Find(What:="line", After:=ActiveCell, LookIn:=xlFormulas, _
        LookAt:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
        MatchCase:=False, SearchFormat:=False)

If cell Is Nothing Then
    'do it something

Else
    'do it another thing
End If

But it is used to find only the cell value which contains as Line.

Upvotes: 0

Views: 125

Answers (1)

YowE3K
YowE3K

Reputation: 23974

To reference the cell which is one row below, and zero columns to the right of, the cell referred to by your cell variable you can use cell.Offset(1, 0).

(Obviously, this can only be done if cell isn't Nothing, so needs to be used only in the Else leg of your code's If statement.)

Upvotes: 2

Related Questions