VBA delete blank rows

JoeyGaspard

Board Regular
Joined
Jul 22, 2019
Messages
147
I am trying to use the code below to delete the entire row if the corresponding cell in Column B is empty. It works only if there is nothing in the other columns, such as, if B5 is blank, but G5 is not, it doesnt delete the row? Thanks in advance.

'Delete Blank Rows if No Data in cells in Column B
On Error Resume Next
Sheets("GeneralJournal").Select
Range("B17:B500").Select
Selection.SpecialCells(xlCellTypeBlanks).EntireRow.Delete
Range("B17").Select
 
Glad we could help & thanks for the feedback

Fluff, I am encountering the same issue again. I have 2 macros that are identical, 1 is for Business Unit 03, and the other is for Business Unit 04, they are identical except for which sheets they run on and the data they process, it works perfectly on the macro for 03, but when I run the macro for 04, it adds about 400+ lines of blank data which will bomb the upload I am trying to do?? Can I send you my spreadsheet and let you take a look at it, I am at my wits end here.....sorry for the trouble in advance
 
Upvote 0

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.
To specify the sheet, it would be...

VBA Code:
With Sheets("GeneralJournal").Range("B17:B500")
   .Value = .Value
   .SpecialCells(xlBlanks).EntireRow.Delete
End With

... which is better than relying on the ActiveSheet anyway.
 
Upvote 0
Maybe
VBA Code:
With Range("B17:B500")
   .Value = .Value
   .SpecialCells(xlBlanks).EntireRow.Delete
   .Parent.UsedRange
End With
 
Upvote 0
Here is the code I use in both macros: It deletes the blank rows for one, but not the other?


On Error Resume Next
Sheets("GeneralJournal").Select
With Range("B17:B500")
.Value = .Value
.SpecialCells(xlBlanks).EntireRow.Delete
End With
Range("B17").Select
 
Upvote 0
In that case can you supply the file?
To do so, you will need to upload it to a share site such as OneDrive, DropBox. Mark it for sharing & post the link.
 
Upvote 0
Thanks for that.
The problem is that your data is in a table & it doesn't let you delete entire rows if they are not contiguous.
Try
VBA Code:
With Sheets("GeneralJournal").ListObjects("Table1").ListColumns("Main account").DataBodyRange
   .Value = .Value
   .SpecialCells(xlBlanks).Delete
End With
Range("B17").Select
 
Upvote 0
Thanks for that.
The problem is that your data is in a table & it doesn't let you delete entire rows if they are not contiguous.
Try
VBA Code:
With Sheets("GeneralJournal").ListObjects("Table1").ListColumns("Main account").DataBodyRange
   .Value = .Value
   .SpecialCells(xlBlanks).Delete
End With
Range("B17").Select
Thank you so much! As always, your help is greatly appreciated.
 
Upvote 0
Glad we could help & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,215,038
Messages
6,122,798
Members
449,095
Latest member
m_smith_solihull

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