ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Delete extra rows at the end of macro run (https://www.excelbanter.com/excel-programming/288702-delete-extra-rows-end-macro-run.html)

jmatchus[_2_]

Delete extra rows at the end of macro run
 
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

--
Message posted from http://www.ExcelForum.com


mudraker[_115_]

Delete extra rows at the end of macro run
 
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

--
Message posted from http://www.ExcelForum.com


jmatchus[_3_]

Delete extra rows at the end of macro run
 
That worked perfectly, thank you VERY much for your help. I reall
appreciate it

--
Message posted from http://www.ExcelForum.com



All times are GMT +1. The time now is 03:15 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com