ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   adding cell data into a macro to allow specified information filte (https://www.excelbanter.com/excel-programming/330024-adding-cell-data-into-macro-allow-specified-information-filte.html)

mattguerilla

adding cell data into a macro to allow specified information filte
 

I have a macro which filters information in a worksheet and then copies
certain columns of the filtered data to another worksheet. The macro that
does this already contains the filter criteria. What I would like to do is
allow a user to type information into a given cell which the macro will read
and use as the filter criteria (when the macro runs). Can this be done?

JE McGimpsey

adding cell data into a macro to allow specified information filte
 
One way:


Sheets("Sheet1").Range("A1").AutoFilter _
Field:=1, _
Criteria1:=Sheets("Sheet1").Range("J10").Value, _
VisibleDropDown:=True



Or, more efficiently:

With Sheets("Sheet1")
.Range("A1").AutoFilter, _
Field:=1, _
Criteria1:=.Range("J10").Value, _
VisibleDropDown:=True
End With





In article ,
mattguerilla wrote:

I have a macro which filters information in a worksheet and then copies
certain columns of the filtered data to another worksheet. The macro that
does this already contains the filter criteria. What I would like to do is
allow a user to type information into a given cell which the macro will read
and use as the filter criteria (when the macro runs). Can this be done?


Tom Ogilvy

adding cell data into a macro to allow specified information filte
 
Using Autofilter?

instead of Criteria1:="ABC"

put in

Criteria1:=Worksheets(1).Range("E9").Value

--
Regards,
Tom Ogilvy


"mattguerilla" wrote in message
...

I have a macro which filters information in a worksheet and then copies
certain columns of the filtered data to another worksheet. The macro that
does this already contains the filter criteria. What I would like to do

is
allow a user to type information into a given cell which the macro will

read
and use as the filter criteria (when the macro runs). Can this be done?




mattguerilla

adding cell data into a macro to allow specified information f
 
thankyou very much lads...excellent

Matt


All times are GMT +1. The time now is 11:27 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com