Headers of Tables in a report

30percent

Board Regular
Joined
May 5, 2011
Messages
107
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

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.

Forum statistics

Threads
1,196,130
Messages
6,013,624
Members
441,777
Latest member
Lleuadwen

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