Delete TABLE rows if cell is empty

BODYCOTE

New Member
Joined
May 18, 2021
Messages
21
Office Version
  1. 365
Platform
  1. Windows
  2. MacOS
I have the following table that I want to delete each row if cell 'S' is empty so I can generate a pivot table without junk data

i have tried the following already and receive error:
1623300678418.png
1623300711859.png


This is what it looks like after I try to run the current macro (I'd like it to be table range specific so i dont have to enter false data from S1:S4)

1623300606562.png
 

Excel Facts

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.
I don't use a Mac, but this worked for me. Check you table name and column heading in the code.
Test with a copy of your workbook.

VBA Code:
Sub DeleteTableRows()
  Dim r As Long
  
  With Range("Table1[stock to order]")
    For r = .Rows.Count To 1 Step -1
      If IsEmpty(.Cells(r).Value) Then .ListObject.ListRows(r).Delete
    Next r
  End With
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,865
Messages
6,121,988
Members
449,060
Latest member
mtsheetz

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