I've got a sub where I want to copy a cell which has been selected by a user, then go to a column in another workbook then filter that column by the cell I've just copied in the first workbook.
Is this possible?
I've done the steps using the recorder, but it didn't give me what I expected.
In the example below, I'm copying cell A2 in Sheet1 of a file called "File1" then going to another file called "FilterFile" then applying the filter then pasting it.
In this case, it just pasted the word "Cake" (which was in cell A2 in the first sheet). But is there a way to make it paste whatever word was in cell A2 in the first sheet? Eg if it was "Crisps"?
Is this possible?
I've done the steps using the recorder, but it didn't give me what I expected.
In the example below, I'm copying cell A2 in Sheet1 of a file called "File1" then going to another file called "FilterFile" then applying the filter then pasting it.
In this case, it just pasted the word "Cake" (which was in cell A2 in the first sheet). But is there a way to make it paste whatever word was in cell A2 in the first sheet? Eg if it was "Crisps"?
VBA Code:
Sub filter_2()
Windows("File1"). _
Activate
Sheets("Sheet1").Select
Range("A2").Select
Selection.Copy
Windows("FilterFile.xlsx").Activate
ActiveSheet.Range("$A$1:$BG$498941").AutoFilter Field:=4, Criteria1:= _
"Cake"
End Sub