Copy a row from one sheet to another sheet if the row contains a certain value

前端 未结 1 902
囚心锁ツ
囚心锁ツ 2021-01-03 16:51

This shouldn\'t be complicated code, but I am new to Excel VBA. I\'ve tried many different methods resulting in bugs, infinite loops, and wrong selections.

I need t

相关标签:
1条回答
  • 2021-01-03 17:18
    Sub Test()
    For Each Cell In Sheets(1).Range("J:J")
        If Cell.Value = "131125" Then
            matchRow = Cell.Row
            Rows(matchRow & ":" & matchRow).Select
            Selection.Copy
    
            Sheets("Sheet2").Select
            ActiveSheet.Rows(matchRow).Select
            ActiveSheet.Paste
            Sheets("Sheet1").Select
        End If
    Next
    End Sub
    
    0 讨论(0)
提交回复
热议问题