willisom24
New Member
- Joined
- Nov 5, 2017
- Messages
- 7
I have a workbook with an input sheet (sheet1) and multiple data sheets after that. Column X in each data sheet contains dates that are filtered. I have copied the following VBA code from another user to update the filters for the single date I want to filter in all sheets. It is as follows:
Sub apply_autofilter_across_worksheets()
Dim xWs As Worksheet
On Error Resume Next
For Each xWs In Worksheets
xWs.Range("x6").AutoFilter 1, "12/29/2017"
Next
End Sub
This macro is running well. What I want to change is the "12/29/2017". How can I instead have the macro pull the date from cell A3 of the input sheet (sheet1), rather than always having to update the date in the actual code each time? I will never need to filter more than one date at a time, so I will not need to use multiple criteria.
Any help would be greatly appreciated as I am a novice at VBA.
Sub apply_autofilter_across_worksheets()
Dim xWs As Worksheet
On Error Resume Next
For Each xWs In Worksheets
xWs.Range("x6").AutoFilter 1, "12/29/2017"
Next
End Sub
This macro is running well. What I want to change is the "12/29/2017". How can I instead have the macro pull the date from cell A3 of the input sheet (sheet1), rather than always having to update the date in the actual code each time? I will never need to filter more than one date at a time, so I will not need to use multiple criteria.
Any help would be greatly appreciated as I am a novice at VBA.