VBA return multiple rngs that match criteria

BarefootPaul

Board Regular
Joined
Jul 21, 2011
Messages
54
I have one sheet (Active) that has a table (tblActive) on it and another that I want to use as a dashboard of sorts. On the Dashboard sheet I have a range named "Provider" that has list data validation setup . I'd like a user to be able to select a name from the Provider list and below that return every instance of that from the table in the provider field (Provider1), plus some offset ranges. I have some ideas of how to do it, but am feeling a bit stumped. Here is some of what I imagine I might need and I appreciate any suggestions.

Code:
Private Sub Worksheet_Change(ByVal Target As Range)

Dim rProvider As Range, rList As Range ', rSearch As Range
Dim ws As Worksheet, wsActive As Worksheet
Dim i As Integer
Dim count As Double
Dim objTable As ListObject
Dim rSearch As ListColumns

Set ws = ActiveWorkbook.Sheets("Dashboard")
Set wsActive = ActiveWorkbook.Sheets("Active")
Set rProvider = ws.Range("Provider")
Set rList = rProvider.Offset(1, 0)
Set objTable = wsActive.ListObjects("tblActive")
Set rSearch = objTable.ListColumns("Provider1").Range 'Fails here

If Target.Row = 14 Then
    count = Application.WorksheetFunction.CountIf(rSearch, rProvider) 'Not sure how to do the first arg in vba
    For i = 1 To count
        Find match 'I'll need to figure out this and am open to suggestions for alternate methods than I have written out here.
        rList = match
        rList.Offset(0, 1) = match.Offset(0, 4)
        rList.Offset(0, 2) = match.Offset(0, 17)
        rList = rList.Offset(1, 0)
        i = i + 1
    Next i
End If
End Sub

I am hoping it will look something like this after:
ProviderSam smithhoursdate
Clientsjohn310/12/2012
jane411/4/2012
david811/19/2012

<tbody>
</tbody>

I am using Excel 2010.
Thanks
 
Last edited:

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().

Forum statistics

Threads
1,215,633
Messages
6,125,925
Members
449,274
Latest member
mrcsbenson

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top