| | Post: 1 | Registrato il: 03/03/2017
| Città: MILANO | Età: 21 | Utente Junior | 2016 | | OFFLINE | |
|
03/03/2017 17:28 | |
Buonasera,
avrei necessità di costruire una macro che, alla chiusura o al lancio del file, mi cancella i filtri inseriti nelle varie tabelle (presenti in vari fogli della cartella di lavoro).
So come si imposta una macro al lancio ma non riesco a trovare un comando che mi cancelli i filtri dalle tabelle di tutti i fogli (non eliminare i filtri, solo cancellarli).
Grazie mille,
Frappo300 |
|
| | Post: 2.886 | Registrato il: 21/06/2013
| Città: NAPOLI | Età: 70 | Utente Veteran | Excel 365 | | OFFLINE |
|
03/03/2017 19:11 | |
Se ho capito bene prova questa macro da inserire nel modulo di ThisWorkbook
vb Private Sub Workbook_BeforeClose(Cancel As Boolean)
Dim i As Integer
For i = 1 To Sheets.Count
If Sheets(i).AutoFilterMode = True Then
Sheets(i).AutoFilterMode = False
End If
End Sub
Alfredo |
| | Post: 3.743 | Registrato il: 13/03/2012
| Città: LIVORNO | Età: 78 | Utente Master | 2010 | | OFFLINE | |
|
03/03/2017 19:20 | |
in questi casi così semplici basta attivare il registratore di macro, effettuare manualmente l'operazione, fermare il registratore e la macro è pronta
----------
Win 10 - Excel 2010
allega un file di esempio, guadagnerai tempo tu e lo farai risparmiare a chi ti aiuta |
| | Post: 2.887 | Registrato il: 21/06/2013
| Città: NAPOLI | Età: 70 | Utente Veteran | Excel 365 | | OFFLINE |
|
03/03/2017 19:27 | |
Hai perfettamente ragione Andrea
Io l'ho scritta solo perchè si trattava di procedura evento contenente un ciclo For che non si possono creare con il registratore.
Alfredo |
| | Post: 3.744 | Registrato il: 13/03/2012
| Città: LIVORNO | Età: 78 | Utente Master | 2010 | | OFFLINE | |
|
03/03/2017 22:53 | |
Non ho ragione Alfredo, non avevo letto attentamente la richiesta di Frappo, scusatemi.
----------
Win 10 - Excel 2010
allega un file di esempio, guadagnerai tempo tu e lo farai risparmiare a chi ti aiuta |
| | Post: 1 | Registrato il: 03/03/2017
| Città: MILANO | Età: 21 | Utente Junior | 2016 | | OFFLINE | |
|
06/03/2017 09:22 | |
Grazie mille per la risposta.
Purtroppo mi da errore perché non è presente il comando next alla fine del ciclo for. L'ho inserito ma mi fornisce un altro errore - autofiltermode non utilizzabile per i worksheet.
Grazie per la disponibilità |
| | Post: 2.888 | Registrato il: 21/06/2013
| Città: NAPOLI | Età: 70 | Utente Veteran | Excel 365 | | OFFLINE |
|
06/03/2017 09:40 | |
Frappo allega il tuo file di esempio.
Alfredo |
| | Post: 2 | Registrato il: 03/03/2017
| Città: MILANO | Età: 21 | Utente Junior | 2016 | | OFFLINE | |
|
06/03/2017 13:08 | |
Ecco qui un file simile.
Grazie mille |
| | Post: 2.889 | Registrato il: 21/06/2013
| Città: NAPOLI | Età: 70 | Utente Veteran | Excel 365 | | OFFLINE |
|
06/03/2017 13:56 | |
Ciao Frappo
Prova così.
vb Private Sub Workbook_BeforeClose(Cancel As Boolean)
Dim i As Integer
For i = 1 To Sheets.Count
If Sheets(i).AutoFilterMode = True Then
Sheets(i).AutoFilterMode = False
End If
Next i
ActiveWorkbook.Save
End Sub
Alfredo |
| | Post: 3 | Registrato il: 03/03/2017
| Città: MILANO | Età: 21 | Utente Junior | 2016 | | OFFLINE | |
|
06/03/2017 15:39 | |
Grazie mille! Fantastico!!!!
Per caso potete consigliarmi un modo per imparare il VBA? Link, video, libri..
Ho fatto un po' di programmazione (C++ e Matlab) ma mi piacerebbe imparare meglio..
Grazie davvero! |
| | Post: 2.890 | Registrato il: 21/06/2013
| Città: NAPOLI | Età: 70 | Utente Veteran | Excel 365 | | OFFLINE |
|
06/03/2017 15:43 | |
A questo link trovi un pdf con un corso sul VBA fatto molto bene; ovviamente è solo l'inizio.
https://www.dropbox.com/s/igpcld8arpofztd/Ebook%20VBA.pdf?dl=0
Alfredo |
|
|