Excel VBA to Delete Only Visible Rows in Table

jski21

Board Regular
Joined
Jan 2, 2019
Messages
155
Office Version
  1. 2016
Platform
  1. Windows
Good day all,

Trying to delete only visible rows in a table once I've filtered out unnecessary data. Using this code but keep getting a "Delete method of Range class failed" error at the Selection.EntireRow.Delete command. Tried a few logical (to me anyway) changes but to no avail:

'Clear unwanted rows
With Sheets("Trial Balance by SubFund").ListObjects("TrialBal")
Intersect(.DataBodyRange.SpecialCells(xlVisible), .Parent.Range("A:O")).Select
Selection.EntireRow.Delete
End With


Any guidance would be appreciated. Thanks.


jski
 

Excel Facts

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result
Hi jski21
try this code:
VBA Code:
Application.DisplayAlerts = False
Sheets("Trial Balance by SubFund").ListObjects("TrialBal").DataBodyRange.SpecialCells(xlCellTypeVisible).Delete
Application.DisplayAlerts = True
 
Upvote 0
Solution
Thanks Sequoyah. That did the trick!


jski
 
Upvote 0

Forum statistics

Threads
1,223,986
Messages
6,175,789
Members
452,670
Latest member
nogarth

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