VBA Question - Find next empty cell in column E and then select entire row

Look4Jay

New Member
Joined
Dec 28, 2016
Messages
2
Hi Guys,

Could you please help me to write a VBA code?

I want to find a next empty cell in column E, then select the entire row and eventually select everything below and delete it. Below is an example for your reference.
A B
1 Account Code Account Name
2 1111 Bank Name
3 1112 Bank Name
4 1113 Bank Name
5 1114 Bank Name
6 1115
7 1116
8 1117
9 1118

So eventually I want the VBA code can delete everything from Row 6, based on the next empty cell under column B.

Currently I can only find one VBA code but that only helps me to select the next empty row in column E.

Range("E" & Rows.Count).End(xlUp).Offset(1).Select

Thanks a lot guys.
 

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.
Hi Look4Jay,

Welcome to MrExcel!!

Try this (firstly on a copy of your data as the results cannot be undone if they're not as expected):

Code:
Option Explicit
Sub Macro1()

    Dim lngLastRow As Long
    
    lngLastRow = Cells.Find("*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row

    Range("B1:B" & lngLastRow).SpecialCells(xlBlanks).EntireRow.Delete

End Sub

Regards,

Robert
 
Upvote 0

Forum statistics

Threads
1,214,647
Messages
6,120,722
Members
448,987
Latest member
marion_davis

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