View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
burl_rfc burl_rfc is offline
external usenet poster
 
Posts: 24
Default List Index filtering

In the following example I'd like to do something a little different
with the list index and I'm not sure how to go about it.

In the Private Sub Userform_Initialize() routine I'd like to see only
the listing for specific records, let's say in column 2 I have listed
all the product types, for example, Glass, Metals and Crystals and I'd
like to see only the Glass catagory populate into the combo box in the
Private Sub CommandButton1_Click() routine, how can this be done.


Private Sub CommandButton1_Click()

Dim myVar As Variant 'String/Long/double???
Dim myVar1 As String

With Me.ComboBox1
If .ListIndex -1 Then
myVar = .List(.ListIndex, 1) '<-- second column!
MsgBox myVar 'for testing only
myVar1 = .List(.ListIndex, 0)
Select Case myVar
Case Is = "Glass"
frmGlassQuoteForm.Show
End Select
End If
End With
End Sub

Private Sub Userform_Initialize()
Dim SourceWB As Workbook
Dim myRng As Range

With Me.ComboBox1
.ColumnCount = 2
.ColumnWidths = "12;0" 'hide the second column
.Clear
Set SourceWB = Workbooks.Open("C:\TEMP\Quote Models\Quote
Log.xls", False, True)
With SourceWB.Worksheets(1)
Set myRng = .Range("A3:DR" & .Cells(.Rows.Count,
"A").End(xlUp).Row)
End With
.List = myRng.Value
SourceWB.Close False
End With
End Sub

Thanks
burl_rfc