Excel VBA - Delete empty rows

0 votes

I want to get rid of the empty rows that my ERP quotation produces. I'm trying to go through the entire document (A1:Z50) and eliminate any rows where the cells are empty (A1-B1...Z1 = empty, A5-B5...Z5 = empty).

I found this, but can't seem to configure it for me.

On Error Resume Next
Worksheet.Columns("A:A").SpecialCells(xlCellTypeBlanks).EntireRow.Delete
On Error GoTo 0
Nov 16, 2022 in Others by Kithuzzz
• 38,010 points
643 views

1 answer to this question.

0 votes

Try this:

sub foo()
  dim r As Range, rows As Long, i As Long
  Set r = ActiveSheet.Range("A1:Z50")
  rows = r.rows.Count
  For i = rows To 1 Step (-1)
    If WorksheetFunction.CountA(r.rows(i)) = 0 Then r.rows(i).Delete
  Next
End Sub
answered Nov 17, 2022 by narikkadan
• 63,420 points

Related Questions In Others

0 votes
1 answer

Unhide rows in Excel with VBA

Paste this code into a module of ...READ MORE

answered Oct 1, 2022 in Others by narikkadan
• 63,420 points
594 views
0 votes
1 answer

Excel VBA remove blank rows from specific range

I have tried to avoid .select  Option Explicit Sub CombineData() ...READ MORE

answered Oct 23, 2022 in Others by narikkadan
• 63,420 points
815 views
0 votes
1 answer

How do delete an specific page in a word document using Excel VBA?

Check the code below. I eliminated the ...READ MORE

answered Nov 21, 2022 in Others by narikkadan
• 63,420 points
1,014 views
0 votes
1 answer

Need help to delete rows in VBA

Here is a basic macro that deletes ...READ MORE

answered Jan 13, 2023 in Others by narikkadan
• 63,420 points
248 views
0 votes
1 answer

Retrieve epay.info Balance with VBA and Excel

This code should log you in, provided ...READ MORE

answered Sep 5, 2018 in Blockchain by digger
• 26,740 points
904 views
0 votes
1 answer

How to load file to Excel Power query from SFTP site

Currently, I don't think there is a ...READ MORE

answered Dec 3, 2018 in Power BI by Upasana
• 8,620 points
3,223 views
0 votes
1 answer

Using VBA Excel to create a gramatically correct list

The Excel AND function is a logical ...READ MORE

answered Feb 9, 2022 in Others by gaurav
• 23,260 points
514 views
0 votes
2 answers

How to copy a formula horizontally within a table using Excel VBA?

Hi so basically, create an adjacent column ...READ MORE

answered Feb 16, 2022 in Others by Edureka
• 13,670 points
757 views
0 votes
1 answer

Deleting Empty rows in Excel using VBA

On Error Resume Next worksheet.Columns("A:A").SpecialCells(xlCellTypeBlanks).EntireRow.Delete On Error GoTo 0 When ...READ MORE

answered Oct 7, 2022 in Others by narikkadan
• 63,420 points
1,033 views
0 votes
1 answer

Delete all rows in filtered range Except first filtered row in excel VBA

Use a flag to omit first row Sub ...READ MORE

answered Jan 8, 2023 in Others by narikkadan
• 63,420 points
1,511 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP