VBA Help

JoeyGaspard

Board Regular
Joined
Jul 22, 2019
Messages
147
Hi all, I have a spreadsheet where I am trying to use VBA to delete all rows if the cell in column B is blank, for some reason it is not working? The code I am using is listed below, any help is greatly appreciated!


'Delete Blank Rows if No Data in cells in Column B
On Error Resume Next
Sheets("GeneralJournal").Select
With Range("B17:B500")
.Value = .Value
.SpecialCells(xlBlanks).EntireRow.Delete
End With
Range("B17").Select

Thanks!
 

Excel Facts

What is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.
So I am guessing by your code, that column B has a formula in it, and you are first changing it to a hard-coded value, then trying to delete.
What exactly is that formula in column B?
 
Upvote 0
If you remove this line
VBA Code:
On Error Resume Next
& run the macro again what happens?
 
Upvote 0
VBA Code:
Sub JoeyGaspard()
With Sheets("GeneralJournal")
    .Range("B17:B500").Value = .Range("B17:B500").Value
    .Range("B17:B500").SpecialCells(xlBlanks).EntireRow.Delete
    .Range("B17").Select
End With
End Sub
 
Upvote 0
@VBE313
That is just going to delete rows 17 to 500 regardless of whether they are blank or not.
 
Upvote 0
So you didn't get an error message?
 
Upvote 0
In that case can you please post all the code & answer Joe's question.
 
Upvote 0

Forum statistics

Threads
1,215,221
Messages
6,123,701
Members
449,117
Latest member
Aaagu

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