Excel Table Header Row

ManUBlueJay

Active Member
Joined
Aug 30, 2012
Messages
302
Office Version
  1. 2016
Platform
  1. Windows
I would like table 2 header rows to be linked to some of table 1' header row.
SO when I Change the header in the linked cell in table 1 it automatically changes in in table 2.

As soon as I link it and hit enter it inserts a 0 instead.
Any clues or work around would be appreciated.
 

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off
Formulas are not permitted in structured Table header cells
VBA can be used to make the header cells identical
 
Upvote 0
I have tried this without success:
Range("MDLReportsHeaderRange") = Range("DatabaseReportsHeaderRange").Value

I am using Private Sub Worksheet_Change(ByVal Target As Range) that when I change something in that Header it runs the code.
The code runs but nothing changes
 
Upvote 0
Are you trying to make every header cell identical?
Are the tables in 2 different sheets?
Are they the only tables in those sheets
If so, code below will do what you want (Amend sheet name MDL)
(If not, please detail)

VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    Me.ListObjects(1).HeaderRowRange.Copy Sheets("MDL").ListObjects(1).HeaderRowRange
End Sub
 
Upvote 0
The tables are on 2 separate sheets. Table 1 is 16 Cols wide. Table 2 is 8 Cols Wide.
I want to Update all of Table 2 headers with 8 contiguous Cols that are part of table 1 header row
 
Upvote 0
Amend to match your requirements ...

example1 copies FIRST 8 header cells
Rich (BB code):
Private Sub Worksheet_Change(ByVal Target As Range)
    Me.ListObjects(1).HeaderRowRange.Resize(, 8).Offset(, 0).Copy Sheets("XXX").ListObjects(1).HeaderRowRange
End Sub

example 2 copies 8 header cells starting with 2nd column
Rich (BB code):
Private Sub Worksheet_Change(ByVal Target As Range)
    Me.ListObjects(1).HeaderRowRange.Resize(, 8).Offset(, 1).Copy Sheets("XXX").ListObjects(1).HeaderRowRange
End Sub
 
Upvote 0
That works perfect but it changes the formats. How could I make it only copy the values
 
Upvote 0
In the end I just Formated the Header on Table 1 which is hidden anyway to match Table 2, so it works. It would have been good to know for future education
 
Upvote 0
Try ...
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
   Sheets("XXX").ListObjects(1).HeaderRowRange.Value =  Me.ListObjects(1).HeaderRowRange.Resize(, 8).Offset(, [B]1[/B]).Value
End Sub
 
Upvote 0
Thank you. I tried and it gives me a compile error on Offset(, 1).Value "Expected a list separator or )"
I would be interested what the code inside the offset represent as it would help me understand the code.
Cheers
 
Upvote 0

Forum statistics

Threads
1,214,834
Messages
6,121,873
Members
449,056
Latest member
ruhulaminappu

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