Finding next blank row before pasting data

kshitij_dch

Active Member
Joined
Apr 1, 2012
Messages
362
Office Version
  1. 365
  2. 2016
  3. 2007
Platform
  1. Windows
I have a macro which copy and paste data from one workbook to another , below code only replaces code by copying the content every time , Instead I want macro to find next empty row and paste data in the master

VBA Code:
'## Open both workbooks first:
Set X = Workbooks.Open("C:\Users\K****ij Sharma\Desktop\important.xlsm")
Set Y = Workbooks.Open("\\192.156.10.78\analytics\K****ij\Master.xlsm")

'Now, copy what you want from x:
X.Sheets("Sheet1").Range("A1:AA500").Copy

'Now, paste to y worksheet:
Y.Sheets("sheet1").Range("A1").PasteSpecial

'Close x:
X.Close
Y.Close
 

Excel Facts

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.
Next empty row on Y.Sheets("sheet1") would be
VBA Code:
nRow = Y.Sheets("sheet1").Cells(Rows.Count, "A").End(xlUp).Row + 1
 
Upvote 0
Solution
thanks , it worked !!
Glad could help.

The code is like select the last worksheet row in column A and press Ctrl+ArrowUp which will get you to last occupied row. Then need to add 1 more row 🙂
 
Upvote 0
@k****ij_dch in future when marking a post as the solution, please mark the post that contains the solution, rather than your post saying it worked.
Thanks
 
Upvote 0

Forum statistics

Threads
1,223,898
Messages
6,175,274
Members
452,628
Latest member
dd2

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