View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Gazza Gazza is offline
external usenet poster
 
Posts: 5
Default Autofilter more than 1 worksheet

I have a workbook that contains 4 worksheets, all with lots of data on them.
All have autofilter set up and what I am hoping to achieve is to set the
criteria on 1 worksheet in the first column (say in cell B1) that will then
become the default criteria on all the other worksheets.

I found the following code through google but can't get it to work - I
assume the first macro can be pasted into a module but I'm not sure what to
do with the second bit.

OR is there an easier way

Thanks in advance for any help

Private Sub Worksheet_Calculate() MsgBox
ActiveSheet.AutoFilter.Filters(1).Criteria1
End Sub

'Having tht criteria, it can then be applied to any other filter in any
other sheet.
'CODE
set wsThis = Activesheet
for each ws in worksheets if ws.name < wsThis.name
then ws.autofilter.filter(1).criteria =
right(wsthis.autofilter.filter(1).criteria,len(wst his.autofilter.filter(1).criteria)-1
) end if
next