0% found this document useful (0 votes)
35 views1 page

M Copybelow

This VBA macro copies a range of cells from one worksheet to another, pasting the data below any existing data. It finds the last used row in both the source and destination sheets, then copies the range from the source and pastes it starting at the next empty row in the destination sheet.

Uploaded by

Bambang Heru P
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
35 views1 page

M Copybelow

This VBA macro copies a range of cells from one worksheet to another, pasting the data below any existing data. It finds the last used row in both the source and destination sheets, then copies the range from the source and pastes it starting at the next empty row in the destination sheet.

Uploaded by

Bambang Heru P
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

Option Explicit

Sub Copy_Paste_Below_Last_Cell()
'Find the last used row in both sheets and copy and paste data below existing data.

Dim wsCopy As Worksheet


Dim wsDest As Worksheet
Dim lCopyLastRow As Long
Dim lDestLastRow As Long

'Set variables for copy and destination sheets


Set wsCopy = Workbooks("New-Data.xlsm").Worksheets("Export 2")
Set wsDest = Workbooks("Reports.xlsm").Worksheets("All Data")

'1. Find last used row in the copy range based on data in column A
lCopyLastRow = wsCopy.Cells(wsCopy.Rows.Count, "A").End(xlUp).Row

'2. Find first blank row in the destination range based on data in column A
'Offset property moves down 1 row
lDestLastRow = wsDest.Cells(wsDest.Rows.Count, "B").End(xlUp).Offset(1).Row

'3. Copy & Paste Data


wsCopy.Range("B3:D3").Copy _
wsDest.Range("B" & lDestLastRow)

End Sub

You might also like