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
 

Excel Facts

Excel Wisdom
Using a mouse in Excel is the work equivalent of wearing a lanyard when you first get to college
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
 
Upvote 0

Forum statistics

Threads
1,214,899
Messages
6,122,155
Members
449,068
Latest member
shiz11713

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top