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

logandiana

Board Regular
Joined
Feb 21, 2017
Messages
107
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.
 
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.
 
Upvote 0

Excel Facts

Format cells as time
Select range and press Ctrl+Shift+2 to format cells as time. (Shift 2 is the @ sign).
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.
 
Upvote 0

Forum statistics

Threads
1,215,813
Messages
6,127,026
Members
449,352
Latest member
Tileni

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