How to make a list?

jints92

New Member
Joined
Aug 27, 2012
Messages
11
If I have a list of years (some occurring many times) how do I make a list in the next column to add any years that don't appear. For example:

My list looks like this:
20002001200120022004200420042006

<colgroup><col span="8" width="51"></colgroup><tbody>
</tbody>

I want it to look like this:
20002001200120022003
2004200420042005
2006

<colgroup><col span="10" width="51"></colgroup><tbody>
</tbody>

If anyone can help please?
 

Excel Facts

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).
I know this isn't an easy thing to do but does anyone know how to do it. If there is a way without using VBA that would be best.
 
Upvote 0
Try this:-
Code:
[COLOR="Navy"]Sub[/COLOR] MG27Aug40
[COLOR="Navy"]Dim[/COLOR] RngAc [COLOR="Navy"]As[/COLOR] Range
[COLOR="Navy"]Dim[/COLOR] Dn [COLOR="Navy"]As[/COLOR] Range
[COLOR="Navy"]Dim[/COLOR] c
c = 1
[COLOR="Navy"]Set[/COLOR] RngAc = Range(Range("A1"), Cells(1, Columns.count).End(xlToLeft))
[COLOR="Navy"]For[/COLOR] [COLOR="Navy"]Each[/COLOR] Dn [COLOR="Navy"]In[/COLOR] RngAc
    [COLOR="Navy"]If[/COLOR] c > 1 [COLOR="Navy"]Then[/COLOR]
        [COLOR="Navy"]Do[/COLOR] [COLOR="Navy"]While[/COLOR] Dn - Cells(2, c - 1) > 1
            Cells(2, c) = Cells(2, c - 1) + 1
            c = c + 1
        [COLOR="Navy"]Loop[/COLOR]
    [COLOR="Navy"]End[/COLOR] If
        Cells(2, c) = Dn
        c = c + 1
[COLOR="Navy"]Next[/COLOR] Dn
[COLOR="Navy"]End[/COLOR] [COLOR="Navy"]Sub[/COLOR]
Regards Mick
 
Upvote 0
I know this isn't an easy thing to do but does anyone know how to do it. If there is a way without using VBA that would be best.
I can see a way to do it with formulas but it will take 2 steps.

With your current list, you could add a formula at the end of it that adds the missing years. Then, you'd create a new list that is sorted in ascending order.

Interested in this approach?
 
Upvote 0
I can see a way to do it with formulas but it will take 2 steps.

With your current list, you could add a formula at the end of it that adds the missing years. Then, you'd create a new list that is sorted in ascending order.

Interested in this approach?

Sure, bring it on.
 
Upvote 0
Let's assume the current list is in the range A2:H2.

I'm also assuming that both the min year and max year are present!

Enter this array formula** in I2:

=IFERROR(SMALL(IF(ISNA(MATCH(ROW(INDIRECT(MIN($A2:$H2)&":"&MAX($A2:$H2))),$A2:$H2,0)),ROW(INDIRECT(MIN($A2:$H2)&":"&MAX($A2:$H2)))),COLUMNS($I2:I2)),"")

** array formulas need to be entered using the key
combination of CTRL,SHIFT,ENTER (not just ENTER).
Hold down both the CTRL key and the SHIFT key
then hit ENTER.

Copy across until you get blanks.

Now, create the new list sorted in ascending order...

Enter this formula A5 and copy across until you get blanks:

=IFERROR(SMALL($A2:$Z2,COLUMNS($A5:A5)),"")

Use an end of range that is sure to include all the data in the newly expanded original list.
 
Upvote 0
Maybe...another possible solution

Assuming your data in A2:H2
1999
2001
2001
2002
2004
2004
2006
2006
1999
2000
2001
2001
2002
2003
2004
2004
2005
2006
2006

<TBODY>
</TBODY>


Type in A3 the first value of the serie (1999 in the example above)

Formula in B3
=IF(COUNTIF($A$3:A3,MAX($A$2:$H$2))=COUNTIF($A$2:$H$2,MAX($A$2:$H$2)),"",IF(COUNTIF($A$2:$H$2,A3)>COUNTIF($A$3:A3,A3),A3,A3+1))

copy across till you get a blank cell

M.
 
Upvote 0
This worked. I didn't have the min and max in there but once I saw your formula I was able to tweak the rest to get what I wanted.

Thanks
 
Upvote 0

Forum statistics

Threads
1,216,622
Messages
6,131,777
Members
449,671
Latest member
OALes

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