Change table headers to count from a chosen starting day until the last column

Xalova

Board Regular
Joined
Feb 11, 2021
Messages
80
Office Version
  1. 365
Platform
  1. Windows
  2. Mobile
Okay, so i have a huge table which is roughly about 300 columns long. most of the headers are dates. What i need is that i change only the starting date of the project and the table headers automacially update accordingly.

i would do it simply with "=(cell left to the chosen cell)+1". But that doesnt work since they are table headers. I wanted to try to use VBA to solve this problem, but i wouldnt know where to begin. Maybe with a loop?

thanks in advance
 

Excel Facts

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).
VBA Code:
Dim cll As Range
For Each cll In Range("Table1[#Headers]")
    cll = Date + cll.Column - 1
Next
 
Upvote 0
VBA Code:
Dim cll As Range
For Each cll In Range("Table1[#Headers]")
    cll = Date + cll.Column - 1
Next
thats great, but the headers with state start in the 4th column. From there onwards, how do i change that? I tried it with Range("Table1[[#Headers];[Column2]:[Column300]]") but that didnt work.
 
Upvote 0
VBA Code:
Dim Cll As Range
Dim StartDate As Date
Dim StartCol As Integer
StartDate = DateSerial(2021, 4, 16)
StartCol = 4
For Each Cll In Range("Table1[#Headers]")
    If Cll.Column >= StartCol Then Cll = StartDate + Cll.Column - StartCol
Next
 
Upvote 0

Forum statistics

Threads
1,215,045
Messages
6,122,836
Members
449,096
Latest member
Erald

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