A1VBCode Forums

Copy fixed rows from one sheet and copy next row from other sheet on each click of command button


http://www.a1vbcode.com/vbforums/Topic32259.aspx

By LadyAlina - 2/25/2015

Hi,



What I'm trying to do is copy rows from sheet details one by one on each click however from sheet INV I want to copy fixed row. In the destination sheet it will add to next empty row each time I click on command button. But what my code does it it copys only fixed rows from details sheet. Can anybody help me please.



Private Sub CommandButton1_Click()

Application.ScreenUpdating = False

Dim ws1 As Worksheet, ws2 As Worksheet, ws3 As Worksheet

Dim DestRow As Long

Set ws1 = Sheets("Details")

Set ws2 = Sheets("Inv")

Set ws3 = Sheets("Reg")

DestRow = ws3.Cells(Rows.Count, "A").End(xlUp).Row + 1

ws1.Range("A4").copy ---------------------on next click it should copy A5 then A6

ws3.Range("A" & DestRow).PasteSpecial xlPasteValues

ws1.Range("B4").copy ---------------------on next click it should copy B5 then B6

ws3.Range("D" & DestRow).PasteSpecial xlPasteValues

ws1.Range("C4").copy ---------------------on next click it should copy C5 then C6

ws3.Range("G" & DestRow).PasteSpecial xlPasteValues

ws2.Range("B13").copy ---------------------this should be fixed rows for copying

ws3.Range("N" & DestRow).PasteSpecial xlPasteValues

ws2.Range("H13").copy ---------------------this should be fixed rows for copying

ws3.Range("L" & DestRow).PasteSpecial xlPasteValues

ws2.Range("I28").copy ---------------------this should be fixed rows for copying

ws3.Range("J" & DestRow).PasteSpecial xlPasteValues

ws2.Range("H15").copy ---------------------this should be fixed rows for copying

ws3.Range("K" & DestRow).PasteSpecial xlPasteValues

Application.ScreenUpdating = True

End Sub