VBA Delete rows if blank

rplohocky

Active Member
Joined
Sep 25, 2005
Messages
292
Office Version
  1. 365
Platform
  1. Windows
Hello,
I'm looking for a macro that will look at column A and delete all rows that are blank down to row 400 or the last row that has any data in it, specifically column B. I have a template sheet that uses columns A thru L. I fill data into column A and then have various amounts of rows that have data I don't need and want to delete those rows.

Thank you!
 

Attachments

  • excel clip.JPG
    excel clip.JPG
    196.9 KB · Views: 3

Excel Facts

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.
Try this:
VBA Code:
Sub MyDeleteRows()

    Dim lr As Long
    
'   Find last row with data in column B
    lr = Cells(Rows.Count, "B").End(xlUp).Row
    
'   Select blanks cells in column A and delete entire rows
    Range("A1:A" & lr).SpecialCells(xlCellTypeBlanks).EntireRow.Delete
    
End Sub
 
Upvote 0
Solution
You are welcome.
Glad I was able to help.
 
Upvote 0

Forum statistics

Threads
1,214,575
Messages
6,120,342
Members
448,956
Latest member
Adamsxl

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