LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.misc
Shazbot
 
Posts: n/a
Default Problem using INDEX to select items in listbox

I have a worksheet (Data):

A B C
IMS Line
Accurate y
Banctec y y
Advisor y
Excel y

There are 12 rows. Column A is a list of services, IMS and LIne are
components used by those services. In this example Accurate uses IMS so
there is a y in cell B2.

I have a form with 2 listboxes, one (lbcomp) is autopopulated using
cells B1:C1. the other (lbsource) is autopopulated using cells A2:A12.
When a user selects a component from lbcomp I want all of the services
with a y against them to be highlighted, so if someone chooses IMS I
want Accurate, Banctec and Excel to be selected in lbsource.

So far I have written code which makes a msgbox report whethere the
service is used or not (i haven't quite figured out the selection part
yet). My code works for the first two rows but when it hits the third
time it fails and I get a Runtime error 13, type mismatch error. I am
new to VBA and tend to clone what I can from this group and others so
this has me stumped. The offending code follows:

Private Sub Lbcomp_Click()
Dim iloop As Integer
Dim res As String

For iloop = 0 To lbsource.ListCount - 1


res = Application.Index(Worksheets("Data").Range("b2:c12 "), _
Application.Match(lbcomp.Text, _
Worksheets("Data").Range("b1:c1"), 0), _
Application.Match(lbsource.List(iloop), _
Worksheets("Data").Range("a2:a12"), 0))

If res = "y" Then
MsgBox lbsource.List(iloop) & " uses this component."

Else:
If res = "" Then
MsgBox lbsource.List(iloop) & " doesn 't use this component."

Else

If IsEmpty(res) Then
MsgBox "res is empty!"
End If
End If

End If

Next iloop
End Sub


Any help would be greatly appreciated!
Thanks very much

 
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
autofilter problem emre Excel Worksheet Functions 0 March 29th 05 10:19 PM
Conversion SVC Excel Worksheet Functions 9 February 28th 05 02:29 PM
Mouse continues to select after clicking on a cell in excel. Fletch Excel Discussion (Misc queries) 4 February 22nd 05 02:27 AM
Row Autofit problem Excel 2003 Matthias Klaey Excel Discussion (Misc queries) 0 January 19th 05 05:33 PM
Index Match Problem Scooterdog Excel Worksheet Functions 1 December 21st 04 02:49 AM


All times are GMT +1. The time now is 08:09 PM.

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

About Us

"It's about Microsoft Excel"