View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Dave Peterson Dave Peterson is offline
external usenet poster
 
Posts: 35,218
Default Using combobox to find column

I used a combobox from the control toolbox toolbar.

My month abbreviations were in row 1.

This was the code behind the combobox (in the worksheet module):

Option Explicit
Private Sub ComboBox1_Change()

Dim res As Variant

If Me.ComboBox1.ListIndex < 0 Then
Exit Sub 'nothing selected
End If

res = Application.Match(Me.ComboBox1.Value, Me.Rows(1), 0)

If IsError(res) Then
MsgBox "No month found!"
Else
Me.Cells(1, res).EntireColumn.Select
End If

End Sub



Scotty9349 wrote:

I am working on a rolling 12-month budget spreadsheet. The first of the 12
months can be any month.

What I would like to do is have a combobox populate the months in order Jan,
Feb, etc. Then when the user selects say June it will select the column in
which June resides. Keep in mind that June could be anywhere in the first 12
columns.

I can populate the combobox, but the order the months are populated is
identical to the order the months are listed across the top row.


--

Dave Peterson