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!
 
OK. Thanks for confirming.

Unfortunately, I am unable to download files from my current location (our work computers are "locked down"), but it sounds like Fluff is able to.
Hopefully, he will be able to determine what is going on.
Thank you very much for your help!
 
Upvote 0

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().
That is asking me to sign in, you need to mark the file for sharing & then post the link that it gives you.
I found part of the problem, my lookup on the Pivot tab, is returning a zero instead of a blank

=IFERROR(VLOOKUP($A13,Lookup!$A:$E,2,0),"")
 
Upvote 0
The problem is that your data is in a table, try
VBA Code:
'Clean up Upload
With Sheets("Upload")
        .AutoFilterMode = False
        With .Range("A2", .Range("A" & Rows.Count).End(xlUp))
            .AutoFilter 1, "*(**"
            On Error Resume Next
            .Offset(1).SpecialCells(12).EntireRow.Delete
        End With
        .AutoFilterMode = False
        On Error GoTo 0
    End With
 

'Copy Data from Upload to GeneralJournal
Sheets("Upload").Select
Range(Range("A2:L2"), Range("A2:L2").End(xlDown)).Copy
Worksheets("Generaljournal").Range("B17").PasteSpecial Paste:=xlPasteValues

'Delete Blank Rows if No Data in cells in Column B
   With Sheets("GeneralJournal").ListObjects("Table1")
      .Range.AutoFilter 1, ""
      Application.DisplayAlerts = False
      .DataBodyRange.SpecialCells(xlVisible).Delete
      .Range.AutoFilter
   End With
 
Upvote 0
The problem is that your data is in a table, try
VBA Code:
'Clean up Upload
With Sheets("Upload")
        .AutoFilterMode = False
        With .Range("A2", .Range("A" & Rows.Count).End(xlUp))
            .AutoFilter 1, "*(**"
            On Error Resume Next
            .Offset(1).SpecialCells(12).EntireRow.Delete
        End With
        .AutoFilterMode = False
        On Error GoTo 0
    End With


'Copy Data from Upload to GeneralJournal
Sheets("Upload").Select
Range(Range("A2:L2"), Range("A2:L2").End(xlDown)).Copy
Worksheets("Generaljournal").Range("B17").PasteSpecial Paste:=xlPasteValues

'Delete Blank Rows if No Data in cells in Column B
   With Sheets("GeneralJournal").ListObjects("Table1")
      .Range.AutoFilter 1, ""
      Application.DisplayAlerts = False
      .DataBodyRange.SpecialCells(xlVisible).Delete
      .Range.AutoFilter
   End With
That absolutely fixed the problem, I have never worked with a table in VBA, I have some research to do"), so thank you so much, I greatly appreciate your help!
 
Upvote 0
Glad we could help & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,214,983
Messages
6,122,592
Members
449,089
Latest member
Motoracer88

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