Macro/VBA to allow Filter based on cell value from different Tab

Jzfbkr

New Member
Joined
Aug 4, 2014
Messages
29
INPUT

<tbody>
</tbody>

FixtureHSAS
TEAM A v TEAM B
11
TEAM C v TEAM D21
TEAM E v TEAM F12
TEAM A v TEAM C30

<tbody>
</tbody>


Im looking to try and write a macro to autofilter a table based on the contents on the cell above. This cell is on a different sheet to the table I am looking to filter.

Ideally the I would like to return the following:

TEAM A

<tbody>
</tbody>


FixturesHSAS
TEAM A v TEAM B11
TEAM A v TEAM C30

<tbody>
</tbody>


My range is alot larger using 365R x 225C

Any help with this would be massively appreciated as I am very new to macros.

Thanks
 

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.
Try this:

Code:
Sub FilterTeams()

    Dim LastRow As Long

    LastRow = Range("A" & Rows.Count).End(xlUp).Row

    ActiveSheet.Range("A3:C" & LastRow).AutoFilter Field:=1, Criteria1:="=*" & Range("A1") & "*"

End Sub
This is assuming that your data starts from range A3 and your Input cell is A1.
 
Upvote 0
Excellent! I wont begin to question how it works as I know it will go right over my head.

Where you have put range will i need to substitute for the whole range including column headers or is it just the data. Also is there a way to filter rows that Contain the word/s in the input cell?

I realise you have already helped immensely and its rather cheeky of me to ask for more.

Thank you ever so much
 
Upvote 0
Upvote 0
I am still a little confused...

The input cell is in a sheet called 'Print Out Report' in a merged cell F4:V5

The column I would like to filter is based in a different sheet called 'GOALS ANALYSIS 2.0' cells C4:368 but the range of data I would like it applied to occupies A4:HQ368 on the same sheet.

It sounds like abit of a riddle. Again I'd really appreciate the help, I appreciate your probably very busy but this would make life very easy.

Thanks again.
 
Upvote 0
Perhaps this:
Code:
Sub Macro1()

    Dim sInput  As String

    sInput = Sheets("Print Out Report").Range("F4").Value

    Sheets("GOALS ANALYSIS 2.0").Range("A4:HQ368").AutoFilter Field:=3, Criteria1:="=*" & sInput & "*"

End Sub
 
Upvote 0
Thanks for the sharp reply. I've added this as a module but unfortunatly it doesn't seem to work.

Thanks for all your help on this one. I'll try and think of another way around this issue.
 
Upvote 0
Try this:
Code:
Private Sub Worksheet_Change(ByVal Target As Range)

    If Target.Address = "$F$4" Then
        Sheets("GOALS ANALYSIS 2.0").Range("A4:HQ368").AutoFilter Field:=3, Criteria1:="*" & Target & "*"
    End If

End Sub
Put this code in the code module of the sheet with the input cell.
 
Upvote 0
That has worked a treat! Thank you ever so much Gavin appreciate you taking the time to help twice!!
 
Upvote 0

Forum statistics

Threads
1,221,446
Messages
6,159,917
Members
451,603
Latest member
SWahl

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