Copy 2 cells from 1 sheet to another and add to list

Alex Piotto

Board Regular
Joined
Jul 5, 2016
Messages
82
Office Version
  1. 2007
Platform
  1. Windows
Hi everybody!

Has been a while... got seek, got well, got lucky!

Now...

I have two sheets, named VENDAS and RESUMO.

From VENDAS i am copying two cells, named DATAVENDA and TOTAL.

The 2 cells are not near each other. DATAVENDA is near the top and TOTAL is almost at the end of the sheet. In different columns.

I put a button in the VENDAS sheet. The code of the button is:

---------

Private Sub CommandButton1_Click()
Dim rng As Range
Set rng = Sheets("VENDAS").Range("DATAVENDA, TOTAL")

For Each cell In rng
Sheets("RESUMO").Cells(cell.Row, cell.Column).Value = cell.Value

Next cell

End Sub

---------

I am able to copy the 2 values to the RESUMO sheet, but i need the two values to be in the same row, starting from row 8.

And next time i click the button it should add one new row with the new values, one row below. Every time. To build a list.

Now the values are pasted in the same cells where i copied, one near the top, one near the bottom of VENDAS sheet.

And when i click again the button it will over-wright the values... So...

How do i position the values in the right place to begin with, and how do i add a new row with new values below next time i click the button?

Any help will be fantastic! Thanks
 

Some videos you may like

Excel Facts

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.

Alex Piotto

Board Regular
Joined
Jul 5, 2016
Messages
82
Office Version
  1. 2007
Platform
  1. Windows
Got it...

Private Sub CommandButton1_Click()

lastRow = Sheets("RESUMO").Cells(Rows.Count, "A").End(xlUp).Row

ThisWorkbook.Sheets("VENDAS").Range("DATAVENDA").Copy
ThisWorkbook.Sheets("RESUMO").Range("A" & lastRow + 1).PasteSpecial Paste:=xlPasteValues

ThisWorkbook.Sheets("VENDAS").Range("TOTAL").Copy
ThisWorkbook.Sheets("RESUMO").Range("B" & lastRow + 1).PasteSpecial Paste:=xlPasteValues

Application.CutCopyMode = False

Sheets("RESUMO").Activate
Sheets("RESUMO").Range("B1").Select

End Sub
 

Alex Piotto

Board Regular
Joined
Jul 5, 2016
Messages
82
Office Version
  1. 2007
Platform
  1. Windows
Probably not helping is a kind of help...
 

Watch MrExcel Video

Forum statistics

Threads
1,114,068
Messages
5,545,795
Members
410,708
Latest member
SanTrapGamer
Top