VBA to delete HeaderRowRange

Ann Ooi

New Member
Joined
Jun 12, 2020
Messages
40
Office Version
  1. 365
Platform
  1. Windows
Hi, I just need to delete the header of a table and copy the body range to another worksheet. But not sure what is not right with the code below, it just not able to delete the header.
Following is my code.

VBA Code:
Dim lo As ListObject

 Workbooks("WIP_Macro.xlsm").Sheets("WIP").Activate
    
 Set lo = Worksheets("WIP").ListObjects("WIPFlow")
 lo.HeaderRowRange.Delete
  lo.DataBodyRange.SpecialCells(xlCellTypeVisible).Select
 Selection.Copy
 

Excel Facts

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"
You can copy the DataBodyRange without deleting the header row. Why do you want to delete the header row?
 
Upvote 0
You can copy the DataBodyRange without deleting the header row. Why do you want to delete the header row?
ok, got it. As I don't need the table header, and just need to paste the body range to another worksheet, which already has header and data accumulated. So, the header is not allowed to delete right?
 
Upvote 0
ok, got it. As I don't need the table header, and just need to paste the body range to another worksheet, which already has header and data accumulated. So, the header is not allowed to delete right?
Correct, ListObjects must have a header. If you really need to delete it you can convert the table to a range and then delete the header.
 
Upvote 0

Forum statistics

Threads
1,223,983
Messages
6,175,778
Members
452,668
Latest member
mrider123

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