ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   How do I code a button to filter on worksheet2 (https://www.excelbanter.com/excel-programming/328466-how-do-i-code-button-filter-worksheet2.html)

Jason Ward

How do I code a button to filter on worksheet2
 
I have created a button on worksheet1 and I need code that will allow me
to run my filter for sheet2. I already have the filter code, but I need
code that will focus or run the filter for sheet2. here is the code I am
using that will run the filter it will work if I do it in sheet1 but I
have to open the file in sheet2 because it is a dbf file and because of
the buttons and so forth:
Dim iLastRow As Long
iLastRow = Cells(Rows.Count, "B").End(xlUp).Row
With Range("B1:B" & iLastRow)
.AutoFilter Field:=1, Criteria1:="SC"
.SpecialCells(xlCellTypeVisible).EntireRow.Copy _
Destination:=Worksheets("Sheet2").Range("A1")
.AutoFilter
.AutoFilter Field:=1, Criteria1:="SU"
.SpecialCells(xlCellTypeVisible).EntireRow.Copy _
Destination:=Worksheets("Sheet3").Range("A1")
.AutoFilter
End With

Thanks again to all that have helped out.


*** Sent via Developersdex http://www.developersdex.com ***


All times are GMT +1. The time now is 07:30 AM.

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