Delete extra rows at the end of macro run

J

jmatchus

Hello! Hope all is well!

I created a macro that manipulates some data and it works great
however, one part of the macro takes a value and copies it down th
entire column because it doesn't change.

Unfortunately, the amount of data in the spreadsheet (rows) is dynamic
So when I run the macro on two different sets of data, I sometime
have too much copied down the column so it looks like this:

xxx xxx xxx xxx 0019 xxx xxx xxx
xxx xxx xxx xxx 0019 xxx xxx xxx
xxx xxx xxx xxx 0019 xxx xxx xxx
xxx xxx xxx xxx 0019 xxx xxx xxx
001
 
M

mudraker

If you have a column that always has an entry in the last row of tha
you want to keep and is empty in all the rows you want to remove the
you can use



Dim lRow As Long
lRow = Range("a65536").End(xlUp).Row + 1
Rows(lRow & ":65536").Delete ' or clearcontents



You can also use a similar code to find out how far to copy your dat
down so that you do not end up with the extra data that needs to b
delete
 

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

Top