Good moorning,
I have 4 worksheets:
Sheet1
Sheet2
Sheet3
Sheet4
I would like to know if there is a VBA macro when opening the file, does the "Reapply All" filter (Filter) in all worksheets work?
Thanks for your help.
Good moorning,
I have 4 worksheets:
Sheet1
Sheet2
Sheet3
Sheet4
I would like to know if there is a VBA macro when opening the file, does the "Reapply All" filter (Filter) in all worksheets work?
Thanks for your help.
If I'm understand correctly, try putting something like this in the ThisWorkbook code page
Capture.JPGOption Explicit Private Sub Workbook_Open() Dim ws As Worksheet On Error Resume Next For Each ws In ThisWorkbook.Worksheets ws.AutoFilter.ApplyFilter Next On Error GoTo 0 End Sub
---------------------------------------------------------------------------------------------------------------------
Paul
Remember: Tell us WHAT you want to do, not HOW you think you want to do it
1. Use [CODE] ....[/CODE ] Tags for readability
[CODE]PasteYourCodeHere[/CODE ] -- (or paste your code, select it, click [#] button)
2. Upload an example
Go Advanced / Attachments - Manage Attachments / Add Files / Select Files / Select the file(s) / Upload Files / Done
3. Mark the thread as [Solved] when you have an answer
Thread Tools (on the top right corner, above the first message)
4. Read the Forum FAQ, especially the part about cross-posting in other forums
http://www.vbaexpress.com/forum/faq...._new_faq_item3
You probably have more than one
Sub Workbook_Open()
macros in your project; delete all but the one you want or change the name(s) of the one(s) you don't want to run on file open.
p45cal
Everyone: If I've helped and you can't be bothered to acknowledge it, I can't be bothered to look at further posts from you.
Good morning p45cal,
does not work,
I am attaching the file, so you can see if I was wrong.
Thanks and best regards
The macro that will work when the workbook is opened is:
Private Sub Workbook_Open()
NOT:
Private Sub Workbook_Open1()
so swap their names around.
Want both to work? Then either:or:Private Sub Workbook_Open() Dim oWs As Worksheet Call Tester1 Call Tester2 Call Tester3 Call Tester4 For Each oWs In Worksheets ''///check for AutoFilter, if not in use apply If Not oWs.AutoFilterMode Then oWs.ListObjects(1).Range.AutoFilter Next oWs End Sub
If there isn't a table (listobject) on each worksheet (which there isn't) you might need to cater for that or as a quick fix bring the On Error Resume Next line back in.Private Sub Workbook_Open() Dim oWs As Worksheet For Each oWs In Worksheets ''///check for AutoFilter, if not in use apply If Not oWs.AutoFilterMode Then oWs.ListObjects(1).Range.AutoFilter Next oWs Call Tester1 Call Tester2 Call Tester3 Call Tester4 End Sub
p45cal
Everyone: If I've helped and you can't be bothered to acknowledge it, I can't be bothered to look at further posts from you.
That is a MS Word document with a link in it to some other file sharing service
It'd be better to attach the actual workbook with enough data to show the problem to your post
My sig has instructions
BTW, indicating that you're using Tables instead of Ranges would have been useful information, and would have been obvious from an attached sample workbook
---------------------------------------------------------------------------------------------------------------------
Paul
Remember: Tell us WHAT you want to do, not HOW you think you want to do it
1. Use [CODE] ....[/CODE ] Tags for readability
[CODE]PasteYourCodeHere[/CODE ] -- (or paste your code, select it, click [#] button)
2. Upload an example
Go Advanced / Attachments - Manage Attachments / Add Files / Select Files / Select the file(s) / Upload Files / Done
3. Mark the thread as [Solved] when you have an answer
Thread Tools (on the top right corner, above the first message)
4. Read the Forum FAQ, especially the part about cross-posting in other forums
http://www.vbaexpress.com/forum/faq...._new_faq_item3
So what can I do to attach a 3.2mb zipped file which always tells me failed
Try uploading a smaller sample of your file
Remember To Do the Following....
Use [Code].... [/Code] tags when posting code to the thread.
Mark your thread as Solved if satisfied by using the Thread Tools options.
If posting the same issue to another forum please show the link
Last edited by Paul_Hossler; 11-29-2021 at 04:01 PM.
---------------------------------------------------------------------------------------------------------------------
Paul
Remember: Tell us WHAT you want to do, not HOW you think you want to do it
1. Use [CODE] ....[/CODE ] Tags for readability
[CODE]PasteYourCodeHere[/CODE ] -- (or paste your code, select it, click [#] button)
2. Upload an example
Go Advanced / Attachments - Manage Attachments / Add Files / Select Files / Select the file(s) / Upload Files / Done
3. Mark the thread as [Solved] when you have an answer
Thread Tools (on the top right corner, above the first message)
4. Read the Forum FAQ, especially the part about cross-posting in other forums
http://www.vbaexpress.com/forum/faq...._new_faq_item3
Goodmorning everyone
I am attaching the file, so you can see if I was wrong.
Thanks and best regards
____________________________________________
Nihil simul inventum est et perfectum
Abusus non tollit usum
Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
James Thurber
____________________________________________
Nihil simul inventum est et perfectum
Abusus non tollit usum
Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
James Thurber
Original request from post #1
1. Original answer: YesI would like to know if there is a VBA macro when opening the file, does the "Reapply All" filter (Filter) in all worksheets work?
2. HOWEVER, your file Provo.xlsm wants to use ListObjects, and there aren't any
Capture.JPG
3. Macro recorder for "Reapply" generates this:
Is this what you really want?Sub Macro2() Sheets("2 Mesi Successivi").AutoFilter.ApplyFilter End Sub
4. Based on your workbook, and the question in #1, there's this
5. But I think you need to be very specific about what you want to doOption Explicit Private Sub Workbook_Open() Dim ws As Worksheet On Error Resume Next For Each ws In ThisWorkbook.Worksheets If Not ws.AutoFilterMode Then ws.Rows(1).AutoFilter ws.AutoFilter.ApplyFilter Next On Error GoTo 0 End Sub
EDIT:
6. Is this different from your other post, the files seem to be the same
http://www.vbaexpress.com/forum/show....php?69400-VBA
Last edited by Paul_Hossler; 11-30-2021 at 10:56 AM.
---------------------------------------------------------------------------------------------------------------------
Paul
Remember: Tell us WHAT you want to do, not HOW you think you want to do it
1. Use [CODE] ....[/CODE ] Tags for readability
[CODE]PasteYourCodeHere[/CODE ] -- (or paste your code, select it, click [#] button)
2. Upload an example
Go Advanced / Attachments - Manage Attachments / Add Files / Select Files / Select the file(s) / Upload Files / Done
3. Mark the thread as [Solved] when you have an answer
Thread Tools (on the top right corner, above the first message)
4. Read the Forum FAQ, especially the part about cross-posting in other forums
http://www.vbaexpress.com/forum/faq...._new_faq_item3
Good Morning!
I managed.Thank you and it's a good job!
Option Explicit Private Sub Workbook_Open () Call Tester Call Tester 1 Call Tester2 Call Tester 3 Dim ws As Worksheet On Error Resume Next For Each ws In ThisWorkbook.Worksheets If Not ws.AutoFilterMode Then ws.Rows (1) .AutoFilter ws.AutoFilter.ApplyFilter Next On Error GoTo 0 End Sub
Last edited by Aussiebear; 12-01-2021 at 04:38 AM. Reason: Added code tags to supplied code