È soltanto un Pokémon con le armi o è un qualcosa di più? Vieni a parlarne su Award & Oscar!
 
Pagina precedente | 1 | Pagina successiva
Vota | Stampa | Notifica email    
Autore

Riportare scadenze documenti personali

Ultimo Aggiornamento: 25/10/2016 17:23
Post: 2
Registrato il: 18/10/2016
Età: 43
Utente Junior
2013
OFFLINE
20/10/2016 22:33

Ciao a tutti, vorrei creare uno scadenziario in cui, nel primo foglio riepilogativo da tenere d'occhio ogni giorno, vengano riportate nelle celle solo i documenti in scadenza o scaduti. Non ho idea di che formula utilizzare per realizzarlo. Ho già creato le formule che nei vari fogli dei singoli tipi di documenti mi dicono in base a emissione e scadenza se il documento è scaduto, in scadenza, non inserito o valido. Allego un file di prova - Grazie per i suggerimenti!!
Post: 2.344
Registrato il: 21/06/2013
Città: NAPOLI
Età: 70
Utente Veteran
Excel 365
OFFLINE
20/10/2016 23:18

Ciao Arcanum

Solo una precisazione: sullo scadenziario per ogni documento nelle colonne "In scadenza" e "Scaduto" cosa deve essere riportato? Il nome dell'iscritto?

Alfredo
Post: 2.348
Registrato il: 21/06/2013
Città: NAPOLI
Età: 70
Utente Veteran
Excel 365
OFFLINE
21/10/2016 15:01

Ciao Arcanum78

Ti propongo questa macro che dovrebbe fare quello che chiedi

vb
Sub prova()
Dim i As Integer
Dim colscad As Integer
Dim ur As Long
Dim ur1 As Long
Dim lr As Long
Dim cel As Range
Dim rng As Range
Range("a5:l100").ClearContents
For i = 2 To Sheets.Count
    Select Case Sheets(i).Name
        Case Is = "Patenti"
        colscad = 1
        Case Is = "Tessere sanitarie"
        colscad = 3
        Case Is = "Carta di identità"
        colscad = 5
        Case Is = "Passaporto"
        colscad = 7
        Case Is = "Bancomat"
        colscad = 9
        Case Is = "Carta di credito"
        colscad = 11
    End Select
lr = Sheets(i).Cells(Rows.Count, "D").End(xlUp).Row
Set rng = Sheets(i).Range("D1:D" & lr)
    For Each cel In rng
        ur = Cells(Rows.Count, colscad).End(xlUp).Row
        ur1 = Cells(Rows.Count, colscad + 1).End(xlUp).Row
            If cel.Value = "IN SCADENZA" Then
                Cells(ur + 1, colscad).Value = cel.Offset(0, -3).Value
                ElseIf cel.Value = "SCADUTA" Then
                Cells(ur1 + 1, colscad + 1).Value = cel.Offset(0, -3).Value
        End If
    Next cel
Next i
End Sub


Dai tuoi fogli ho eliminato delle colonne (che non servivano) e le celle vuote (che al VBA "danno fastidio").

Sul foglio "Scadenziario" ti ho messo un pulsante per il lancio della macro; volendo se ne può fare anche a meno lanciando la macro all'attivazione del foglio "Scadenzario".

Ti allego il file e fai sapere.

Alfredo
Post: 2
Registrato il: 18/10/2016
Età: 43
Utente Junior
2013
OFFLINE
21/10/2016 15:36

Re:
alfrimpa, 21/10/2016 15.01:

Ciao Arcanum78 Ti propongo questa macro che dovrebbe fare quello che chiedi
vb
Sub prova() Dim i As Integer Dim colscad As Integer Dim ur As Long Dim ur1 As Long Dim lr As Long Dim cel As Range Dim rng As Range Range("a5:l100").ClearContents For i = 2 To Sheets.Count Select Case Sheets(i).Name Case Is = "Patenti" colscad = 1 Case Is = "Tessere sanitarie" colscad = 3 Case Is = "Carta di identità" colscad = 5 Case Is = "Passaporto" colscad = 7 Case Is = "Bancomat" colscad = 9 Case Is = "Carta di credito" colscad = 11 End Select lr = Sheets(i).Cells(Rows.Count, "D").End(xlUp).Row Set rng = Sheets(i).Range("D1:D" & lr) For Each cel In rng ur = Cells(Rows.Count, colscad).End(xlUp).Row ur1 = Cells(Rows.Count, colscad + 1).End(xlUp).Row If cel.Value = "IN SCADENZA" Then Cells(ur + 1, colscad).Value = cel.Offset(0, -3).Value ElseIf cel.Value = "SCADUTA" Then Cells(ur1 + 1, colscad + 1).Value = cel.Offset(0, -3).Value End If Next cel Next i End Sub 
Dai tuoi fogli ho eliminato delle colonne (che non servivano) e le celle vuote (che al VBA "danno fastidio"). Sul foglio "Scadenziario" ti ho messo un pulsante per il lancio della macro; volendo se ne può fare anche a meno lanciando la macro all'attivazione del foglio "Scadenzario". Ti allego il file e fai sapere.



Ciao e grazie della risposta! Si, nel foglio scadenziario vorrei fossero riportati solo i nomi delle persone con documenti scaduti o in scadenza. Oggi stesso provo il tuo file, intanto grazie
Post: 3
Registrato il: 18/10/2016
Età: 43
Utente Junior
2013
OFFLINE
22/10/2016 14:31

Ho provato il foglio che m hai inviato ed è perfetto per quello che volevo fare!

A questo punto ti chiedo: se io volessi adattarlo al foglio che effettivamente utilizzo, più complesso e con circa 100 iscritti, potrei adattare quello o non è possibile perchè non basta modificare i campi con i nomi dei fogli ecc? (Considera che di macro non ho alcuna esperienza....)

Se non riesco a farlo, esiste una formula o più formule Excel che sostituiscano la macro? [SM=x423017]
Post: 2.350
Registrato il: 21/06/2013
Città: NAPOLI
Età: 70
Utente Veteran
Excel 365
OFFLINE
22/10/2016 21:57

Ciao Arcanum

La macro che ho scritto funziona indipendentemente dal numero di record presenti nei fogli dei documenti quindi a te basta copiare in tuoi dati nel mio file e lanciare la macro.

Se hai problemi sono qua.

Alfredo
Post: 4
Registrato il: 18/10/2016
Età: 43
Utente Junior
2013
OFFLINE
24/10/2016 19:42

Ciao e grazie per la disponibilità

Ho provato ad adattare la tua macro alla cartella "definitiva" cambiando il range delle celle nel foglio scadenziario e modificando i nomi dei fogli. Mi dà errore (immagino sia ovvio che lo dia, avrò tralasciato qualcosa) codice 1004. Vorrei anche che al foglio 6 mi riporti "da consegnare", ma non saprei come fare:

Sub prova()
Dim i As Integer
Dim colscad As Integer
Dim ur As Long
Dim ur1 As Long
Dim lr As Long
Dim cel As Range
Dim rng As Range
Range("q8:w35").ClearContents
For i = 2 To Sheets.Count
Select Case Sheets(i).Name
Case Is = "3"
colscad = 1
Case Is = "4"
colscad = 3
Case Is = "5"
colscad = 5
Case Is = "6"
colscad = 7
End Select
lr = Sheets(i).Cells(Rows.Count, "D").End(xlUp).Row
Set rng = Sheets(i).Range("D1:D" & lr)
For Each cel In rng
ur = Cells(Rows.Count, colscad).End(xlUp).Row
ur1 = Cells(Rows.Count, colscad + 1).End(xlUp).Row
If cel.Value = "IN SCADENZA" Then
Cells(ur + 1, colscad).Value = cel.Offset(0, -3).Value
ElseIf cel.Value = "SCADUTA" Then
Cells(ur1 + 1, colscad + 1).Value = cel.Offset(0, -3).Value
End If
Next cel
Next i
End Sub


Ti allego il file pressoché definitivo. Grazie
Post: 2.353
Registrato il: 21/06/2013
Città: NAPOLI
Età: 70
Utente Veteran
Excel 365
OFFLINE
24/10/2016 22:18

Per alegare file con macro devi zipparli.

Rifallo.

Alfredo
Post: 5
Registrato il: 18/10/2016
Età: 43
Utente Junior
2013
OFFLINE
25/10/2016 06:58

Re:
alfrimpa, 24/10/2016 22.18:

Per alegare file con macro devi zipparli.

Rifallo.




Post: 2.354
Registrato il: 21/06/2013
Città: NAPOLI
Età: 70
Utente Veteran
Excel 365
OFFLINE
25/10/2016 12:14

Arcanum il file che hai allegato ora è completamente diverso da quello postato in precedenza per cui la mia macro mai e poi mai avrebbe potuto funzionare.

Quindi va riscritta da capo!

Se avessi postato inizialmente questo file avremmo evitato di perdere tempo inutilmente.

Alfredo
Post: 2.355
Registrato il: 21/06/2013
Città: NAPOLI
Età: 70
Utente Veteran
Excel 365
OFFLINE
25/10/2016 15:40

Allora Arcanum ho dovuto rifare tutto daccapo.

Ho scritto quattro macro per l'aggiornamento dei singoli fogli e una che le richiama tutte collegata al pulsante "Aggiorna" posto sul foglio "SCADENZIARIO"

2^ Macro

Sub AggiornaFoglio3()
Dim ur As Long
Dim ur1 As Long
Dim lr As Long
Dim rng As Range
Dim cel As Range
lr = Worksheets("3").Cells(Rows.Count, "L").End(xlUp).Row
Set rng = Worksheets("3").Range("L4:L" & lr)
Worksheets("SCADENZIARIO").Range("Q7:r35").ClearContents
For Each cel In rng
    If cel.Value = "In scadenza" Then
        ur = Worksheets("SCADENZIARIO").Cells(Rows.Count, "q").End(xlUp).Row
        Worksheets("SCADENZIARIO").Cells(ur + 1, "q").Value = cel.Offset(0, -8).Value
        ElseIf cel.Value = "Scaduta" Then
        ur1 = Worksheets("SCADENZIARIO").Cells(Rows.Count, "r").End(xlUp).Row
        Worksheets("SCADENZIARIO").Cells(ur1 + 1, "r").Value = cel.Offset(0, -8).Value
    End If
Next cel
End Sub


2^ macro

Sub AggiornaFoglio4()
Dim ur As Long
Dim ur1 As Long
Dim lr As Long
Dim rng As Range
Dim cel As Range
lr = Worksheets("4").Cells(Rows.Count, "W").End(xlUp).Row
Set rng = Worksheets("4").Range("W4:W" & lr)
Worksheets("SCADENZIARIO").Range("S7:T35").ClearContents
For Each cel In rng
    If cel.Value = "In scadenza" Then
        ur = Worksheets("SCADENZIARIO").Cells(Rows.Count, "s").End(xlUp).Row
        Worksheets("SCADENZIARIO").Cells(ur + 1, "s").Value = cel.Offset(0, -19).Value
        ElseIf cel.Value = "Scaduta" Then
        ur1 = Worksheets("SCADENZIARIO").Cells(Rows.Count, "t").End(xlUp).Row
        Worksheets("SCADENZIARIO").Cells(ur1 + 1, "t").Value = cel.Offset(0, -19).Value
    End If
Next cel
End Sub


3^ Macro

Sub AggiornaFoglio5()
Dim ur As Long
Dim ur1 As Long
Dim lr As Long
Dim rng As Range
Dim cel As Range
lr = Worksheets("5").Cells(Rows.Count, "j").End(xlUp).Row
Set rng = Worksheets("5").Range("j4:j" & lr)
Worksheets("SCADENZIARIO").Range("U7:v35").ClearContents
For Each cel In rng
    If cel.Value = "In scadenza" Then
        ur = Worksheets("SCADENZIARIO").Cells(Rows.Count, "u").End(xlUp).Row
        Worksheets("SCADENZIARIO").Cells(ur + 1, "u").Value = cel.Offset(0, -7).Value
        ElseIf cel.Value = "Scaduta" Then
        ur1 = Worksheets("SCADENZIARIO").Cells(Rows.Count, "v").End(xlUp).Row
        Worksheets("SCADENZIARIO").Cells(ur1 + 1, "v").Value = cel.Offset(0, -7).Value
    End If
Next cel
End Sub


4^ Macro

Sub AggiornaFoglio6()
Dim ur As Long
Dim ur1 As Long
Dim lr As Long
Dim rng As Range
Dim cel As Range
lr = Worksheets("6").Cells(Rows.Count, "k").End(xlUp).Row
Set rng = Worksheets("6").Range("k4:k" & lr)
Worksheets("SCADENZIARIO").Range("w7:w35").ClearContents
For Each cel In rng
    If cel.Value = "Da consegnare" Then
        ur = Worksheets("SCADENZIARIO").Cells(Rows.Count, "w").End(xlUp).Row
        Worksheets("SCADENZIARIO").Cells(ur + 1, "w").Value = cel.Offset(0, -8).Value
    End If
Next cel
End Sub


5^ Macro

Sub AggiornaTutto()
    Call AggiornaFoglio4
    Call AggiornaFoglio5
    Call AggiornaFoglio6
End Sub


Fai sapere.

Alfredo
Post: 6
Registrato il: 18/10/2016
Età: 43
Utente Junior
2013
OFFLINE
25/10/2016 16:20

ho provato a scarica il file che hai appena caricato, ma credo sia il primo file che ho inviato giorni fa, non l'ultimo
Post: 2.358
Registrato il: 21/06/2013
Città: NAPOLI
Età: 70
Utente Veteran
Excel 365
OFFLINE
25/10/2016 16:36

Forse ho sbagliato

Riprovo

Alfredo
Post: 7
Registrato il: 18/10/2016
Età: 43
Utente Junior
2013
OFFLINE
25/10/2016 17:23

Re:
alfrimpa, 25/10/2016 16.36:

Forse ho sbagliato

Riprovo





Tutto funzionante!

Ho dovuto solo aggiungere la riga "aggiornafoglio3" alla macro nr. 5.
Ovviamente non era mia intenzione farti perdere tempo inutilmente, per me, da profano, era sufficiente una modifica alla macro, non una riscrittura. L'avessi saputo non avrei rifatto il file, ma ampliato ed evoluto il precedente.

Grazie per l'aiuto



Vota:
Amministra Discussione: | Chiudi | Sposta | Cancella | Modifica | Notifica email Pagina precedente | 1 | Pagina successiva
Nuova Discussione
 | 
Rispondi
Feed | Forum | Bacheca | Album | Utenti | Cerca | Login | Registrati | Amministra
Tutti gli orari sono GMT+01:00. Adesso sono le 00:18. Versione: Stampabile | Mobile | Regolamento | Privacy
FreeForumZone [v.6.1] - Copyright © 2000-2024 FFZ srl - www.freeforumzone.com