#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Combo Box

Hi,
I require some help using a combo box in Excel. I wish to use a
combo box to select a number from a list of about 10 and then go to
another worksheet in the book and filter a column based on the number
selected in the combo box.
I have got as far as populating the combo box with the required
numbers, but stuck with the VBA code needed to take the figure and
then filter the column with it.
If the combo box is in sheet1 and the column that needs to be filtered
in column A of sheet 2, what VBA code would i need to do this?

Thanks in advance.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,339
Default Combo Box

Hi,

Try this - assume C1 on Sheet1 contains the combobox value::

CritValue = Worksheets("Sheet1").Range("C1") ' Set to your value from the
combobox

Worksheets("Sheet2").Columns("A:A").Select
Selection.AutoFilter
Selection.AutoFilter Field:=1, Criteria1:=CritValue

' Or

Selection.AutoFilter Field:=1, Criteria1:=Worksheets("Sheet1").Range("c1")

HTH


"Thomas Earnshaw" wrote:

Hi,
I require some help using a combo box in Excel. I wish to use a
combo box to select a number from a list of about 10 and then go to
another worksheet in the book and filter a column based on the number
selected in the combo box.
I have got as far as populating the combo box with the required
numbers, but stuck with the VBA code needed to take the figure and
then filter the column with it.
If the combo box is in sheet1 and the column that needs to be filtered
in column A of sheet 2, what VBA code would i need to do this?

Thanks in advance.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,758
Default Combo Box

I put a combobox from the control toolbox toolbar on a worksheet.

I used this code behind that worksheet:

Option Explicit
Private Sub ComboBox1_Change()
With Worksheets("sheet2")
If .AutoFilterMode Then
If .FilterMode Then
.ShowAllData
End If
If Me.ComboBox1.Value < "" Then
.AutoFilter.Range.AutoFilter field:=1, _
Criteria1:=Me.ComboBox1.Value
End If
Else
MsgBox "Please apply autofilter to sheet2!"
End If
End With
End Sub


I used sheet2 and column 1 of the filtered range (already applied).

Thomas Earnshaw wrote:

Hi,
I require some help using a combo box in Excel. I wish to use a
combo box to select a number from a list of about 10 and then go to
another worksheet in the book and filter a column based on the number
selected in the combo box.
I have got as far as populating the combo box with the required
numbers, but stuck with the VBA code needed to take the figure and
then filter the column with it.
If the combo box is in sheet1 and the column that needs to be filtered
in column A of sheet 2, what VBA code would i need to do this?

Thanks in advance.


--

Dave Peterson
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Combo Box

Thanks Toppers,
This Works great!


Toppers wrote:
Hi,

Try this - assume C1 on Sheet1 contains the combobox value::

CritValue = Worksheets("Sheet1").Range("C1") ' Set to your value

from the
combobox

Worksheets("Sheet2").Columns("A:A").Select
Selection.AutoFilter
Selection.AutoFilter Field:=1, Criteria1:=CritValue

' Or

Selection.AutoFilter Field:=1,

Criteria1:=Worksheets("Sheet1").Range("c1")

HTH


"Thomas Earnshaw" wrote:

Hi,
I require some help using a combo box in Excel. I wish to use a
combo box to select a number from a list of about 10 and then go to
another worksheet in the book and filter a column based on the

number
selected in the combo box.
I have got as far as populating the combo box with the required
numbers, but stuck with the VBA code needed to take the figure and
then filter the column with it.
If the combo box is in sheet1 and the column that needs to be

filtered
in column A of sheet 2, what VBA code would i need to do this?

Thanks in advance.


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
linking a form combo box... results from the combo box to another Trey Excel Discussion (Misc queries) 1 July 15th 07 01:58 AM
combo reference on another combo box for picking address etc. kbjin Excel Worksheet Functions 1 December 8th 06 03:29 PM
In Excel I need to set up a combo box based on another combo box. donna_ge Excel Discussion (Misc queries) 2 March 29th 06 03:26 PM
"Combo Box - getting control combo box to stick in place in worksh ajr Excel Discussion (Misc queries) 1 February 16th 05 02:05 AM
"Combo Box - getting control combo box to stick in place in worksh ajr Excel Discussion (Misc queries) 0 February 15th 05 07:45 PM


All times are GMT +1. The time now is 05:47 PM.

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"