Macro to Duplicate Specifically named Columns and Rename them as a date

Faintkitara

Board Regular
Joined
Jun 23, 2016
Messages
59
Hello,

I'm trying to figure out how to make a macro that copies all columns named " Current Projection" in row 4 and pastes them right after each other. So wherever a column says "Current Projection" in row 4 i pretty much want that column to be duplicated. I tried doing this myself but of course macrorecorder can only go so far. For example row 4 would look like this (with corresponding data below it):

[TABLE="width: 500"]
<tbody>[TR]
[TD]5/5[/TD]
[TD]5/12[/TD]
[TD]Current Projection[/TD]
[TD]Accounts[/TD]
[TD]Current Projection[/TD]
[TD]Totals[/TD]
[/TR]
</tbody>[/TABLE]

I want it to look like this:

[TABLE="width: 500"]
<tbody>[TR]
[TD]5/5[/TD]
[TD]5/12[/TD]
[TD]Current Projection [/TD]
[TD]Current Projection[/TD]
[TD]Accounts[/TD]
[TD]Current Projection[/TD]
[TD]Current Projection [/TD]
[TD]Totals[/TD]
[/TR]
</tbody>[/TABLE]



On top of that I also wanted to get code on how to rename every first "Current Projection" column of the duplicates, a date that is seven days more than the date listed the column before it.

So from this:

[TABLE="width: 500"]
<tbody>[TR]
[TD]5/5[/TD]
[TD]5/12[/TD]
[TD]Current Projection[/TD]
[TD]Current Projection[/TD]
[TD]Accounts [/TD]
[TD]7/2[/TD]
[TD]7/9[/TD]
[TD]Current Projection[/TD]
[TD]Current Projection[/TD]
[TD]Totals[/TD]
[/TR]
</tbody>[/TABLE]

To this:

[TABLE="width: 500"]
<tbody>[TR]
[TD]5/5[/TD]
[TD]5/12[/TD]
[TD]5/19[/TD]
[TD]Current Projection[/TD]
[TD]Current Projection[/TD]
[TD]Accounts[/TD]
[TD]7/2[/TD]
[TD]7/9[/TD]
[TD]7/16[/TD]
[TD]Current Projection[/TD]
[/TR]
</tbody>[/TABLE]


Any response would be greatly appreciated! Thank you!!!
 

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