How to find next record..

  • Thread starter Thread starter peterlee516
  • Start date Start date
P

peterlee516

Hi...

Can someone help me write a code to find the next empty row?

I am running a macro to cut and paste rows from one file to another an
need to make sure that whenever I run this macro the new informatio
doesn't over-ride the previous pasted information.



Sheets(x).Select
Range(y)Select
Selection.Copy
Windows("Other File).Activate
Range("A1").Select <-- my guess is to make this non-static.
ActiveSheet.Paste


Thank you in advanc
 
Change

Range("A1").Select

to

Range("A65000").End(xlUp).Offset(1,0).Select
 
Peter

This code will copy Sheet2!A1:J10 to ActiveSheet first empty row at bottom of
Column A.


Worksheets("Sheet2").Range ("A1:J10").Copy Destination:= _
ActiveSheet.Cells(Rows.Count, 1).End(xlUp) _
.Offset(1, 0)


Adjust to suit your sheets and ranges

Gord Dibben Excel MVP
 
Replace Range("A1").Select with this short code:

k=1:while cells(k,1)<>"":k=k+1:wend
Range("A"&k).select

Good Luck!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top