Macro using cell value

bruce21

New Member
Joined
Oct 25, 2018
Messages
13
Hello all,

I need help on this please. I need to use the value from cell (B5)'sheet1' in a filter on sheet2.

When I record my macro I am copying and pasting the value of B5 over to sheet2 filter and then copying and pasting the results back over to sheet1. This is working but the problem is that I can't reset the value from the previous selection. I've tried using the clear filter button in the macro but the old value is still there. See code below.

Would the Criteria1: be equal to cell b5 and not Ace Hardware? How would I code that?

Thanks to all!
BD


Code:
Range("B5").Select
    Selection.Copy
    Sheets("Account Track").Select
    ActiveSheet.Range("$A$1:$AF$357").AutoFilter Field:=1, Criteria1:= _
        "=*Ace Hardware*", Operator:=xlAnd
    Cells.Select
    Application.CutCopyMode = False
    Selection.Copy
    Sheets("Sheet1").Select
    Range("A17").Select
    ActiveSheet.Paste
    Range("A17").Select
    Sheets("Account Track").Select
    Range("A1").Select
    Application.CutCopyMode = False
    ActiveSheet.ShowAllData
    Sheets("Sheet1").Select
 
Last edited by a moderator:

Excel Facts

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.
Cell B5 is a drop down list to select different customer names that I want to filter on in the Account Track sheet.

Thanks.
 
Upvote 0
Will the names in B5 exactly match the names in the table?
 
Upvote 0
In that case you can use
Code:
 ActiveSheet.Range("$A$1:$AF$357").AutoFilter Field:=1, Criteria1:= _
        [COLOR=#0000ff]Sheets("Sheet1").Range("B5").Value[/COLOR]
 
Upvote 0
You're welcome & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,214,634
Messages
6,120,659
Members
448,975
Latest member
sweeberry

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