Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default Using combobox to find column

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.

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 43
Default Using combobox to find column

Scotty,

You can use the listindex property to find the column. As you say the order
of the months appear the same as the order in the worksheet. Let's say the
combobox is populated as follows:

March, April, May, June etc.

The listindex for March will be 1, April 2 and so on.

For example if you would like to jump to column in which May resides you
could use the following code:
cells(1,combobox.listindex).select

Regards,

Brotha lee

"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.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default Using combobox to find column

Thanks.

Is there a way to have the combobox be Jan, Feb, Mar,... but the columns be
in a different order, i.e. Mar, Apr, May,...?

I would like to have the combobox(Jan, Feb,...) the same regardless of the
first column, i.e. Mar and still index to the corresponding column?
  #4   Report Post  
Posted to microsoft.public.excel.programming
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
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default Using combobox to find column

Thanks. Worked wonderfully.
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
return item from second column from2 column combobox vqthomf Excel Programming 1 March 28th 08 11:04 AM
Find something in column a then find if column B matches criteria Darrell_Sarrasin via OfficeKB.com Excel Discussion (Misc queries) 8 November 28th 07 09:40 PM
Add 2nd Column to ComboBox Justin[_14_] Excel Programming 4 September 14th 06 06:34 PM
Find ALL WorkSheets according to 2 ComboBox Values.... Help with Code Corey Excel Programming 5 July 7th 06 11:33 PM
Slow 'FIND' when entering a value in Combobox bdn435 Excel Programming 0 April 25th 06 12:55 PM


All times are GMT +1. The time now is 01:02 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"