Copy and Paste a set range in the next empty row

前端 未结 4 1133
时光取名叫无心
时光取名叫无心 2020-12-15 13:19

This should be simple but I am having a tough time.. I want to copy the cells A3 through E3, and paste them into the next empty row on a different worksheet. I have used thi

4条回答
  •  一生所求
    2020-12-15 14:21

    Below is the code that works well but my values overlap in sheet "Final" everytime the condition of <=11 meets in sheet "Calculator"

    I would like you to kindly support me to modify the code so that the cursor should move to next blank cell and values keeps on adding up like a list.

    Dim i As Integer
    Dim ws1 As Worksheet: Set ws1 = ThisWorkbook.Sheets("Calculator")
    Dim ws2 As Worksheet: Set ws2 = ThisWorkbook.Sheets("Final")
    
    For i = 2 To ws1.Range("A65536").End(xlUp).Row
    
        If ws1.Cells(i, 4) <= 11 Then
    
            ws2.Cells(i, 1).Value = Left(Worksheets("Calculator").Cells(i, 1).Value, Len(Worksheets("Calculator").Cells(i, 1).Value) - 0)
            ws2.Cells(i, 2) = Application.VLookup(Cells(i, 1), Worksheets("Calculator").Columns("A:D"), 4, False)
            ws2.Cells(i, 3) = Application.VLookup(Cells(i, 1), Worksheets("Calculator").Columns("A:E"), 5, False)
            ws2.Cells(i, 4) = Application.VLookup(Cells(i, 1), Worksheets("Calculator").Columns("A:B"), 2, False)
            ws2.Cells(i, 5) = Application.VLookup(Cells(i, 1), Worksheets("Calculator").Columns("A:C"), 3, False)
    
        End If
    Next i
    

提交回复
热议问题