Cannot remove extra lines with VBA or manually!!??

logandiana

Board Regular
Joined
Feb 21, 2017
Messages
105
I've got code that takes a sheet copies it.
Then uses
VBA Code:
With billPO
LR1 = billPO.Cells(Rows.Count, 3).End(xlUp).Row
.Range(.Rows(LR1 + 1), .Rows(LR1 + 1).End(xlDown)).Delete
End With
To delete everything under the last row (usually around 700 rows).
Then the workbook is saved.

When I go check the saved workbook after the procedure. I've got my data but after the 700 or so rows of data, I've got blank rows all the way down to the bottom (1048576)
Not sure why this is happening this time in particular as this method has always worked before.
BUT here's the kicker.
When I manually open the workbook. Go to the 1st blank row after the last row of data.
I select the row, then do a ctrl shift down, right click and Delete. All the empty rows appear to delete.
I save and close. I have done this method without problem before as well.

But I go back into the workbook and the blank rows are still there.

Not sure what is happening.
 

cmowla

Board Regular
Joined
Sep 21, 2021
Messages
243
Office Version
  1. 365
Platform
  1. Windows
A very bold statement, hopefully a true one as well.
Sure is. I have dealt with this a lot. I have found for certain worksheets, the first sub will do just fine (and is faster). But the second never failed on any sheet I ran it on.
 

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".

logandiana

Board Regular
Joined
Feb 21, 2017
Messages
105
Okay, figured out what was causing it.
After I did the sheet copy.
I did
VBA Code:
.columns("C").value = .columns("M").value
after stepping through it I found that this line caused the scroll bar to go to the bottom
I changed it to
VBA Code:
.range("C1:C" & LR1).value = .range("M1:M" & LR1).value
Works as it should now.
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,152,574
Messages
5,770,928
Members
425,652
Latest member
Pemby

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
Top