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

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).
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,247
Messages
6,171,007
Members
452,374
Latest member
keccles

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