Display following year in combo box

Av8tordude

Well-known Member
Joined
Oct 13, 2007
Messages
1,075
Office Version
  1. 2019
Platform
  1. Windows
I have sheet tabs that are named by the year (i.e. New Report, 2011, 2010 2009, etc). The code below displays the sheet tabs in the combo (which works fine). But, Instead of "New Report" being an option to select, I would like to display the next consecutive year. (i.e. 2012). Will someone assist. Thanks

Code:
Private Sub cboYear_Enter()
Dim Sh As Worksheet

If EE Then Exit Sub
EE = False
With cboYear
    For Each Sh In ActiveWorkbook.Sheets
        If ((Sh.Name <> "Security") And (Sh.Name <> "f2106")) Then
            .AddItem Sh.Name
        End If
    Next
End With
EE = True
End Sub
 

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.
Code:
Private Sub cboYear_Enter()
Dim Sh As Worksheet
Dim NxtYr as long

If EE Then Exit Sub
EE = False
With cboYear
    For Each Sh In ActiveWorkbook.Sheets
        If ((Sh.Name <> "Security") And (Sh.Name <> "f2106")) Then
            .AddItem Sh.Name
            if val(sh.name)>nxtYr the nxtyr=val(sh.name)
        End If
    Next
    .additem nxtyr + 1
End With
EE = True
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,566
Messages
6,179,553
Members
452,928
Latest member
101blockchains

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