Define a table by its borders?

JenniferMurphy

Well-known Member
Joined
Jul 23, 2011
Messages
2,676
Office Version
  1. 365
Platform
  1. Windows
Suppose I have a table like the one below. As it stand now, the data is in D6:G11. I want to define a dynamic named range ("Table") that is, at the moment, D5:G11. If I add a row anywhere between 5 and 12 or a column anywhere between C and H, I want Table to automatically expand.

[TABLE="class: grid, width: 448"]
<tbody>[TR]
[TD="width: 64, align: center"]R/C[/TD]
[TD="width: 64, align: center"]C[/TD]
[TD="width: 64, align: center"]D[/TD]
[TD="width: 64, align: center"]E[/TD]
[TD="width: 64, align: center"]F[/TD]
[TD="width: 64, align: center"]G[/TD]
[TD="width: 64, align: center"]H[/TD]
[/TR]
[TR]
[TD="align: center"]4[/TD]
[TD="align: center"]Hd/C1
[/TD]
[TD="align: center"]TblHead[/TD]
[TD="align: center"]TblHead[/TD]
[TD="align: center"]TblHead[/TD]
[TD="align: center"]TblHead[/TD]
[TD="align: center"]Hd/CN[/TD]
[/TR]
[TR]
[TD="align: center"]5[/TD]
[TD="align: center"]TblCol1
[/TD]
[TD="align: center"]Date
[/TD]
[TD="align: center"]Price
[/TD]
[TD="align: center"]Weight
[/TD]
[TD="align: center"]$$/lb[/TD]
[TD="align: center"]TblColN
[/TD]
[/TR]
[TR]
[TD="align: center"]6[/TD]
[TD="align: center"]TblCol1[/TD]
[TD="align: center"]5/01/19 [/TD]
[TD="align: center"]$25.00 [/TD]
[TD="align: center"]5.0 lb [/TD]
[TD="align: center"]$5.00 [/TD]
[TD="align: center"]TblColN
[/TD]
[/TR]
[TR]
[TD="align: center"]7[/TD]
[TD="align: center"]TblCol1[/TD]
[TD="align: center"]4/22/19 [/TD]
[TD="align: center"]$50.00 [/TD]
[TD="align: center"]12.0 lb [/TD]
[TD="align: center"]$4.17 [/TD]
[TD="align: center"]TblColN[/TD]
[/TR]
[TR]
[TD="align: center"]8[/TD]
[TD="align: center"]TblCol1[/TD]
[TD="align: center"]3/14/19 [/TD]
[TD="align: center"]$12.50 [/TD]
[TD="align: center"]4.0 lb [/TD]
[TD="align: center"]$3.13 [/TD]
[TD="align: center"]TblColN[/TD]
[/TR]
[TR]
[TD="align: center"]9[/TD]
[TD="align: center"]TblCol1[/TD]
[TD="align: center"]5/03/19 [/TD]
[TD="align: center"]$99.00 [/TD]
[TD="align: center"]30.0 lb [/TD]
[TD="align: center"]$3.30 [/TD]
[TD="align: center"]TblColN
[/TD]
[/TR]
[TR]
[TD="align: center"]10[/TD]
[TD="align: center"]TblCol1[/TD]
[TD="align: center"]4/07/19 [/TD]
[TD="align: center"]$35.00 [/TD]
[TD="align: center"]7.5 lb [/TD]
[TD="align: center"]$4.67 [/TD]
[TD="align: center"]TblColN[/TD]
[/TR]
[TR]
[TD="align: center"]11[/TD]
[TD="align: center"]TblCol1[/TD]
[TD="align: center"]3/30/19 [/TD]
[TD="align: center"]$19.95 [/TD]
[TD="align: center"]5.0 lb [/TD]
[TD="align: center"]$3.99 [/TD]
[TD="align: center"]TblColN[/TD]
[/TR]
[TR]
[TD="align: center"]12[/TD]
[TD="align: center"]Ft/C1[/TD]
[TD="align: center"]TblFoot
[/TD]
[TD="align: center"]TblFoot[/TD]
[TD="align: center"]TblFoot[/TD]
[TD="align: center"]TblFoot[/TD]
[TD="align: center"]Ft/CN[/TD]
[/TR]
</tbody>[/TABLE]

For example, if I add a row between 5 & 6, then Table will become D5:G12. If I then add a column between G & H, Table will become D5:H12. And so on...

I have defined these 4 named ranges:

[TABLE="class: grid, width: 200"]
<tbody>[TR]
[TD]TblHead[/TD]
[TD]$4:$4[/TD]
[/TR]
[TR]
[TD]TblFoot[/TD]
[TD]$12:$12[/TD]
[/TR]
[TR]
[TD]TblCol1[/TD]
[TD]$C:$C[/TD]
[/TR]
[TR]
[TD]TblColN[/TD]
[TD]$H:$H[/TD]
[/TR]
</tbody>[/TABLE]

These form a border around the table area (shown in red). I am able to access the upper-left & lower-right corners of my target table with these expressions.

[TABLE="class: grid, width: 400"]
<tbody>[TR]
[TD]R/C[/TD]
[TD="align: center"]A[/TD]
[TD="align: center"]B[/TD]
[/TR]
[TR]
[TD]1[/TD]
[TD]Date[/TD]
[TD]C15: =OFFSET(TblCol1 TblHead,1,1)[/TD]
[/TR]
[TR]
[TD]2[/TD]
[TD]3.99[/TD]
[TD]C16: =OFFSET(TblColN TblFoot,-1,-1)[/TD]
[/TR]
</tbody>[/TABLE]

Next I tried to combine these expressions into a dynamic named range. In Name Manager, I assign this string to the name "Table":

Code:
=OFFSET(TblCol1 TblHead,1,1):OFFSET(TblColN TblFoot,-1,-1)
Then I try to select it using Ctrl+g, but Table is not listed. When I reopen name manager, I see that it exists, but the string has been changed to:
Code:
=OFFSET('Dynamic Table'!TblCol1 'Dynamic Table'!TblHead,1,1):OFFSET('Dynamic Table'!TblColN 'Dynamic Table'!TblFoot,-1,-1)
"Dynamic Table" is the name of the sheet.

What am I doing wrong?
 

Excel Facts

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.

Forum statistics

Threads
1,223,249
Messages
6,171,031
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