Headers of Tables in a report

30percent

Board Regular
Joined
May 5, 2011
Messages
118
Office Version
  1. 2016
Platform
  1. Windows
Hi,

I copy and paste a report statement to my excel each time. It contains many tables within the report. I have a macro to delete every row except for rows that contain a "text" (table in this case) as shown below and paste the header back to the table after initially being deleted as part of rows that doesn't contain the "text" as specified in the code.

I wonder if there is a more efficient way of keeping the header by not deleting it in the first place as opposed to pasting it @ the end - this way, I could probably use it for my other report statement to clean up the blank rows and other data rows that I don't need without deleting the first header.

Sample Table
Report Name
Reporting Time
Statement Period
New York
Client IDClient NameItemAmountRefering Agent
1JohnTable1Hammett
2MariaDesk2Sam
North Carolina
Client IDClient NameItemAmountRefering Agent
1JohnSofa1Hammett
3RobertSofa1Jennifer
South Carolina
Client IDClient NameItemAmountRefering Agent
2MariaTable2Sam
4MicahBed1Hammett

<tbody>
</tbody>

Macro Code
For i = Selection.Rows.Count To 1 Step -1

If (Cells(i, "G").Value) <> "Table" Then

Selection.Rows(i).EntireRow.Delete


End If


Next i


Range("A1").Select
Selection.Insert Shift:=xlDown
Range("A1").Value = "Client ID"
Range("B1").Value = "Client Name"
Range("C1").Value = "Item"
Range("D1").Value = "Amount"
Range("E1").Value = "Referring Agent"
"
 

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.

Forum statistics

Threads
1,214,985
Messages
6,122,603
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