Find first empty row and copy/paste data

Faygin

New Member
Joined
May 12, 2020
Messages
23
Office Version
  1. 365
  2. 2019
Platform
  1. Windows
Looked around and tried to modify existing code but without success.

I have a workbook with a command button.
When i press the button i want to copy the data and paste it in another workbook.

But it has to be on the first available empty row, so that i dont destroy the old data.

So far the code looks like this:

Private Sub CommandButton1_Click()

'This is the data i want to copy
Range("E3:M8").Select
Selection.Copy

'Open the workbook which i want to paste into
Workbooks.Open "O:\abc\def\ghi.xlsx"

' Select the sheet and range A1
Application.Goto Workbooks("NPD Beläggningsprofil.xlsx").Sheets("DATA").Range("A1")

--
Now i want to find the first empty row on the sheet "DATA" and paste or copy the code from the other worksheet.
If the first cell in the row is empty, then i consider the whole row as empty and can be written data to.

Any suggestions and pointers are much appreciated!
 
Is it easy to modify the code to just copy the values?

VBA Code:
Private Sub CommandButton1_Click()

 
 Range("E3:M8").Copy Workbooks("NPD Beläggningsprofil.xlsx").Sheets("DATA").Cells(Rows.Count, "A").End(xlUp)(2)
    
    
End Sub

Now i get the formulas and formatting from E3:M8, it would be even smoother if i could get just the values/text from those cells.
 
Upvote 0

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.
One option...
VBA Code:
Private Sub CommandButton1_Click() 
Range("E3:M8").Copy 
Workbooks("NPD Beläggningsprofil.xlsx").Sheets("DATA").Cells(Rows.Count, "A").End(xlUp)(2).PasteSpecial xlValues        
End Sub
 
Upvote 0

Forum statistics

Threads
1,223,896
Messages
6,175,259
Members
452,626
Latest member
huntinghunter

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