Deleting row - shift cells up issue

falcios

Active Member
Joined
Aug 30, 2006
Messages
279
Office Version
  1. 2019
Platform
  1. Windows
A lot of times when I am deleting rows I inadvertently shift cells up. I don't notice until a lot of entries were made. Changes have to be undone and I don't know if I got them all.

Would a macro help in this instance instead of manually deleting it?

Thanks in advance.
 

Excel Facts

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"
Could you give more detail.
If you select a row and Edit > Delete the row is removed and shift cells up.
Would you like to only remove the value and keep an empty row.
If you detail the way when it's running correctly we can prepare a macro.
 
Upvote 0
I press ALT E, then D for delete and R for row to delete the entire row. I go through it so quickly that by the time I hit enter it shifts the cells up instead of deleting the row.

I hope this makes sense.
 
Upvote 0
Yes but why are you deleting them - blanks, 0, certain value ...?
 
Upvote 0
This is for column A

Code:
Sub test()
Dim LR As Long, i As Long
On Error Resume Next
Columns("A").SpecialCells(xlCellTypeBlanks).EntireRow.Delete shift:=xlShiftUp
LR = Range("A" & Rows.Count).End(xlUp).Row
For i = LR To 1 Step -1
    If WorksheetFunction.CountIf(Columns("A"), Range("A" & i)) > 1 Then Rows(i).Delete
Next i
On Error GoTo 0
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,994
Messages
6,122,633
Members
449,092
Latest member
bsb1122

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