Excel VBA найти следующее значение - PullRequest
0 голосов
/ 26 сентября 2018

Мне нужно получить следующую запись в листе «SQL».Я написал код, чтобы найти значение из листа "temp1", но я хочу найти следующее значение.

Sub Macro1()
    Sheets("candidate data").Select
    With ActiveSheet
        .Cells(.Rows.Count, 1).End(xlUp).EntireRow.Select
        .Cells(.Rows.Count, 1).End(xlUp).EntireRow.Copy
        'Participant details gets updated
        Sheets("Temp1").Activate
        'Paste the row in a transpose format
        Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
                               :=False, Transpose:=True
        Rows("1:1").Select
        Application.CutCopyMode = False
        'Search for email
        Dim myvar As Variant
        'Store the name of the assessee in a variable
        myvar = Worksheets("Temp1").Range("A8").Value
        'Search for this assesee name in the list and select the row where the candidate name is there
        'but i need find next value at this point from "SQL" sheet and paste the value in "temp2" sheet
        Sheets("SQL").Select
        Cells.Find(What:=myvar, after:=ActiveCell, LookIn:= _
                   xlFormulas, LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:= _
                   xlNext, MatchCase:=False, SearchFormat:=False).Activate
        'Select the entire row
        ActiveCell.EntireRow.Copy
        'Participant details gets updated
        Sheets("Temp2").Activate
        'Paste the row in a transpose format
        Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
                               :=False, Transpose:=True
        Rows("1:1").Select
        Application.CutCopyMode = False

    End With
End Sub
...