VBA to autofilter another worksheet with a copy done on the previous

osf9

New Member
Joined
Sep 6, 2012
Messages
20
Sorry for the long title, but just wanted to try to explain my problem.

I have 2 worksheets: "Results" and "Trend". I need a macro in order to:

- select a cell in "Results"
- copy the value of the cell
- filter the first column of "Trend" of the value copied

At the beginning of the process, of course, I want the clear the filter previously done on "Trend".

I tried by my own and this is what I get:

Code:
Sub Macro6()
'
' Macro6 Macro
'

'
    Sheets("Trend").Select
    Application.CutCopyMode = False
    ActiveSheet.ShowAllData
    Sheets("Results").Select
    Selection.Copy
    Sheets("Trend").Select
    ActiveSheet.Range("$A$9:$AB$4149").AutoFilter Field:=1, Criteria1:= _
        "9940088806"
End Sub

That's all working good, apart the selection of the filter, where, instead of having a fix value, I need the have a sort of "paste command".

Do you think it's feasible?

Thanks, regards, Carlo
 
Maybe try:

Rich (BB code):
Sub Macro6()
'
' Macro6 Macro
'
'
    Dim Crit As Variant
    Sheets("Trend").Select
    Application.CutCopyMode = False
    ActiveSheet.ShowAllData
    Sheets("Results").Select
    Crit = Selection.Value
    Sheets("Trend").Select
    ActiveSheet.Range("$A$9:$AB$4149").AutoFilter Field:=1, Criteria1:=Crit
End Sub
 
Upvote 0
Andrew... Faster than light, but most important... PERFECT!

Thanks for your help, appreciated.
 
Upvote 0

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