Insert columns with missing years using VBA in Excel

mvaldez

New Member
Joined
Jan 11, 2021
Messages
9
Office Version
  1. 365
Platform
  1. Windows
Dear experts.

I have been trying in various ways to insert the columns with the consecutive years that are missing in the row, but have not succeeded yet. The values of the years can vary and the distances of the cells between the years.

I would greatly appreciate your valuable help.

Before...
Macro to insert missing values in a range-Tov Meod.xlsm
ABCDEFGHIJKLMNOPQRSTUVWXYZAAABACAD
1
2
3
4
52007200820132015201820202021
6
7
8
16


After...
Macro to insert missing values in a range-Tov Meod.xlsm
ABCDEFGHIJKLMNOPQRSTUVWXYZAAABACAD
1
2
3
4
520072008200920102011201220132014201520152018201820202021
6
7
8
15


The years that are in red are the missing years and that must be added to the row.

Thanks in advance for your help.
 

Excel Facts

Links? Where??
If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.
Sorry.

After 2015 must be added 2016 and after 2018 must be added 2019.

Macro to insert missing values in a range-Tov Meod.xlsm
ABCDEFGHIJKLMNOPQRSTUVWXYZAAABACADAE
1Macro: InsertYearsIA
2
3
4
520072008200920102011201220132014201520162018201920202021
6
7
15
 
Upvote 0

Forum statistics

Threads
1,214,919
Messages
6,122,259
Members
449,075
Latest member
staticfluids

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