lady_alina
Board Regular
- Joined
- Feb 18, 2015
- Messages
- 52
Hi,
I have a 3 sheeter excel, what I want is to copy fixed rows from one sheet named: Inv and copy next row each time I click the button from sheet: Details and paste values to specified cells in sheet: Reg. The code I have at present does that however it pastes the formula and not the values and fixed rows from Customer sheet from where I want next row on each click. Please help me to get the right code. Here is my code given below:
I have a 3 sheeter excel, what I want is to copy fixed rows from one sheet named: Inv and copy next row each time I click the button from sheet: Details and paste values to specified cells in sheet: Reg. The code I have at present does that however it pastes the formula and not the values and fixed rows from Customer sheet from where I want next row on each click. Please help me to get the right code. Here is my code given below:
Code:
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 ws3.Range("A" & DestRow)
ws1.Range("B4").copy ws3.Range("D" & DestRow)
ws1.Range("C4").copy ws3.Range("G" & DestRow)
ws2.Range("B13").copy ws3.Range("N" & DestRow)
ws2.Range("H13").copy ws3.Range("L" & DestRow)
ws2.Range("I28").copy ws3.Range("J" & DestRow)
ws2.Range("H15").copy ws3.Range("K" & DestRow)
Application.ScreenUpdating = True
End Sub