Delete Row if there is anything except a blank cell below specific data in a cell in a column

Livin404

Well-known Member
Joined
Jan 7, 2019
Messages
743
Office Version
  1. 365
  2. 2019
Platform
  1. Windows
Greetings, I'm hoping to have a VBA that will search in Column A for "NO DEPARTURES". In instances where the word is found and data is in the row immediately below, I would like that row deleted and all the cells in the row shifted up. If there is no data immediately below "NO DEPARTURES", then nothing needs to happen. There is no message box required let me know what action is was accomplished, for it will be apparent by the final product. In the image below row 8 would be deleted and rows below shifted up. Since the row below Row 13 is empty nothing needs to happen.
I know if I wanted just to remove "NO DEPARTURES" I can use the VBA below, but I need to work in the rules described above. Thank you,
DELETE.JPG

VBA Code:
Sub Rowdel()
Dim i As Integer
For i = Cells(Rows.Count, 1).End(xlUp).Row To 1 Step -1

If Cells(i, 1) = "NO DEPARTURES" Then Cells(i, 1).EntireRow.Delete
Next i
End Sub
 
Last edited:

Excel Facts

Last used cell?
Press Ctrl+End to move to what Excel thinks is the last used cell.
Please disregard previous question- with the use of another VBA it resolved this problem. I tried to delete this but could not. Thank you,
 
Upvote 0

Forum statistics

Threads
1,214,641
Messages
6,120,693
Members
448,979
Latest member
DET4492

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