?
Solved

count items in listbox with specific string in column 2

Posted on 2013-11-05
3
Medium Priority
?
314 Views
Last Modified: 2013-11-06
excel 2010 vba
on a userform

I need to update a label with the number of items in a listbox that have a specific value.
in column 2


label12

looking for this term     "EEMRC"

frmR.ListBox1.List(2) = "EEMRC"
??

Thanks
fordraiders
0
Comment
Question by:Fordraiders
3 Comments
 
LVL 43

Expert Comment

by:Saqib Husain, Syed
ID: 39626608
How about a dummy sample for testing?
0
 
LVL 54

Accepted Solution

by:
Rgonzo1971 earned 2000 total points
ID: 39626633
Hi,

pls try
Private Sub Macro4()
Dim intListBox As Integer
Dim intIdx As Integer
For intListBox = 0 To frmR.ListBox1.ListCount - 1
    If frmR.ListBox1.List(intListBox, 2) = "EEMRC" Then
        intIdx = intIdx + 1
    End If
Next
'frmR.Label1 = intIdx
End Sub

Open in new window

Regards
0
 
LVL 35

Expert Comment

by:[ fanpages ]
ID: 39626719
PS. fordraiders: I added a revised version of our ongoing workbook development to your existing thread yesterday...

[ http://www.experts-exchange.com/Software/Office_Productivity/Office_Suites/MS_Office/Excel/Q_28264352.html#a39623969 ]

(As you have listed a new question [here], but not responded to my latest comment, I wondered if you had noticed the addition to the previous question)
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
If you need to forecast numbers -- typically for finance -- the Windows and Mac versions of Excel 2016 have a basket of tools to get the job done.
This Micro Tutorial will demonstrate on a Mac how to change the sort order for chart legend values and decrpyt the intimidating chart menu.
This Micro Tutorial will demonstrate how to use a scrolling table in Microsoft Excel using the INDEX function.

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question