Condividi:        

Macro copia i Valori da fogli per crearne uno pluriennale

Vuoi potenziare i tuoi documenti Word? Non sai come si fa una macro in Excel? Devi creare una presentazione in PowerPoint?
Oppure sei passato a OpenOffice e non sei sicuro di come lavorare al meglio?

Moderatori: Anthony47, Flash30005

Macro copia i Valori da fogli per crearne uno pluriennale

Postdi Zagor57 » 03/07/15 12:18

Buongiorno rieccomi a chiedere il Vostro prezioso AIUTO
Ho la necessità di fare una macro che mi copia più dati (Valori ) da piu fogli del file Corrispettivi per creare un database pluriennale, per poter fare interrogazioni vari......
i fogli in questione sono 12 (GEN-FEB-MAR-APR........DIC) il Range dei valori da copiare comprese 2 colonne protette da tutti i fogli è ("C8:M40) con destinazione al foglio (riepilogo pluriennale) inserendo nella colonna di " SX " l'anno es.( 2015 ) per tutta la lunghezza del mese ,tale dato è presente nel foglio2 nella cella unita " AD-AE-AF (49) "
In fase di copia fra un mese e l'altro di lasciare libere 3 o 4 colonne ( per eventuali inserimento di altri dati).

Una volta terminata la copia i dati inseriti nei fogli (GEN-FEB-MAR-APR........DIC) del Range ("C8:M40) si devono cancellare, in modo da preparare il file per l'anno Nuovo
Naturalmente :
La macro si deve lanciare solo a "fine ANNO a creazione Anno Nuovo " dato che andremo ad inserire nella cella (A1)- foglio1 (es: 31/12.....)

Grazie a presto
Avatar utente
Zagor57
Utente Junior
 
Post: 75
Iscritto il: 04/05/15 19:35
Località: Massafra TA

Sponsor
 

Re: Macro copia i Valori da fogli per crearne uno pluriennal

Postdi Zagor57 » 05/07/15 17:00

Bene sono riuscito attraverso il registratore di macro a creare questa macro che comunque funziona
però ci sono un bel pò di spostamenti in più durante la copia ,mi potete aiutare a pulirla un tantino?
fermo restando tutti i dati perchè ho già iniziato a lavorarci

Codice: Seleziona tutto
Sub CopiaAnno()
'
' CopiaAnno Macro
MsgBox "Attenzione chiusura annuale Selezione nella cella  AH36  ( Si O NO )"
   
    If Sheets("DIC").Range("AH36") = "S" Then    '<<<<<<<<<Condizione di conferma se salvare o non salvare
    Call CopiaAnno
    Else:
    MsgBox ("Dati non Caricati ")
    End If
  Exit Sub

[quote]MsgBox "Attenzione chiusura annuale Selezione nella cella  AH36  ( Si O NO )"
   
    If Sheets("DIC").Range("AH36") = "S" Then    '<<<<<<<<<Condizione di conferma se salvare o non salvare
    Call CopiaAnno
    Else:
    MsgBox ("Dati non Caricati ")
    End If
  Exit Sub[/quote]
'

 '
 '
 '<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<CODIA I DATI in DBvendita
 'GENNAIO
 Sheets("VERIFICA").Select ' <<<<<<<<<<<<<<<<<<<<<<scopre il DBvendita
    Sheets("DBvendita").Visible = True
    Sheets("DBvendita").Select
    ActiveSheet.Unprotect
    Sheets("GEN").Select
    Range("C3:P40").Select
    Selection.Copy
    Sheets("DBvendita").Select
    Range("B1").Select
    Selection.End(xlDown).Select
    Range("C1048576").Select
    Selection.End(xlUp).Select
    ActiveCell.Offset(1, 0).Range("A1").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    ActiveWindow.SmallScroll Down:=18
    ActiveWindow.SmallScroll ToRight:=4
    ActiveCell.Offset(37, 14).Range("A1").Select
    Selection.End(xlDown).Select
    Range("R1048576").Select
    Selection.End(xlUp).Select
 '
 'FEBBRAIO
    Application.CutCopyMode = False
    ActiveSheet.Unprotect
    Sheets("FEB").Select
    Range("c3:P40").Select
    Application.CutCopyMode = False
    Selection.Copy
    Sheets("DBvendita").Select
    ActiveCell.Offset(1, 0).Range("A1").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    ActiveCell.Offset(37, 14).Range("A1").Select
    Selection.End(xlDown).Select
    Range("AG1048576").Select
    Selection.End(xlUp).Select
    ActiveCell.Offset(1, 0).Range("A1").Select
    'MARZO
    Application.CutCopyMode = False
    ActiveSheet.Unprotect
    Sheets("MAR").Select
    Range("c3:P40").Select
    'ActiveSheet.Unprotect
    Application.CutCopyMode = False
    Selection.Copy
    Sheets("DBvendita").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    ActiveCell.Offset(37, 14).Range("A1").Select
    Selection.End(xlDown).Select
    ActiveCell.Offset(0, 1).Range("A1").Select
    Selection.End(xlUp).Select
    ActiveCell.Offset(1, 0).Range("A1").Select
  'APRILE
    Application.CutCopyMode = False
    ActiveSheet.Unprotect
    Sheets("APR").Select
    Range("c3:P40").Select
    'ActiveSheet.Unprotect
    Application.CutCopyMode = False
    Selection.Copy
    Sheets("DBvendita").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    ActiveWindow.SmallScroll ToRight:=14
    ActiveWindow.SmallScroll Down:=18
    ActiveCell.Offset(37, 14).Range("A1").Select
    Selection.End(xlDown).Select
    Range("BK1048576").Select
    Selection.End(xlUp).Select
    ActiveCell.Offset(1, 0).Range("A1").Select
   'MAGGIO
    Application.CutCopyMode = False
    ActiveSheet.Unprotect
    Sheets("MAG").Select
    Range("c3:P40").Select
    'ActiveSheet.Unprotect
    Application.CutCopyMode = False
    Selection.Copy
    Sheets("DBvendita").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    ActiveCell.Offset(37, 15).Range("A1").Select
    Selection.End(xlDown).Select
    Range("CA1048576").Select
    Selection.End(xlUp).Select
    ActiveCell.Offset(1, 0).Range("A1").Select
   'GIUGNO
    Application.CutCopyMode = False
    ActiveSheet.Unprotect
    Sheets("GIU").Select
    Range("c3:P40").Select
    'ActiveSheet.Unprotect
    Application.CutCopyMode = False
    Selection.Copy
    Sheets("DBvendita").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    ActiveCell.Offset(37, 14).Range("A1").Select
    Selection.End(xlDown).Select
    Range("CP1048576").Select
    Selection.End(xlUp).Select
    ActiveCell.Offset(1, 0).Range("A1").Select
   'LUGLIO
    Application.CutCopyMode = False
    ActiveSheet.Unprotect
    Sheets("LUG").Select
    Range("c3:P40").Select
    'ActiveSheet.Unprotect
    Application.CutCopyMode = False
    Selection.Copy
    Sheets("DBvendita").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    ActiveCell.Offset(37, 14).Range("A1").Select
    Selection.End(xlDown).Select
    Range("DE1048576").Select
    Selection.End(xlUp).Select
    ActiveCell.Offset(1, 0).Range("A1").Select
    'AGOSTO
    Application.CutCopyMode = False
    ActiveSheet.Unprotect
    Sheets("AGO").Select
    Range("c3:P40").Select
   ' ActiveSheet.Unprotect
    Application.CutCopyMode = False
    Selection.Copy
    Sheets("DBvendita").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    ActiveCell.Offset(37, 14).Range("A1").Select
    Selection.End(xlDown).Select
    Range("DT1048576").Select
    Selection.End(xlUp).Select
    ActiveCell.Offset(1, 0).Range("A1").Select
    'SETTEMBRE
   Application.CutCopyMode = False
    ActiveSheet.Unprotect
    Sheets("SET").Select
    Range("c3:P40").Select
   ' ActiveSheet.Unprotect
    Application.CutCopyMode = False
    Selection.Copy
    Sheets("DBvendita").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    ActiveWindow.SmallScroll ToRight:=25
    ActiveWindow.SmallScroll Down:=12
    ActiveCell.Offset(38, 14).Range("A1").Select
    Selection.End(xlDown).Select
    Range("EI1048576").Select
    Selection.End(xlUp).Select
    ActiveCell.Offset(1, 0).Range("A1").Select
    'OTTOBRE
    Application.CutCopyMode = False
    ActiveSheet.Unprotect
    Sheets("OTT").Select
    Range("c3:P40").Select
   ' ActiveSheet.Unprotect
    Application.CutCopyMode = False
    Selection.Copy
    Sheets("DBvendita").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    ActiveWindow.SmallScroll Down:=12
    ActiveCell.Offset(37, 14).Range("A1").Select
    ActiveWindow.SmallScroll ToRight:=6
    Selection.End(xlDown).Select
    Range("EX1048576").Select
    Selection.End(xlUp).Select
    ActiveCell.Offset(1, 0).Range("A1").Select
    'NOVEMBRE
    Application.CutCopyMode = False
    ActiveSheet.Unprotect
    Sheets("NOV").Select
    Range("c3:P40").Select
    'ActiveSheet.Unprotect
    Application.CutCopyMode = False
    Selection.Copy
    Sheets("DBvendita").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    ActiveWindow.SmallScroll Down:=16
    ActiveWindow.SmallScroll ToRight:=4
    ActiveCell.Offset(37, 14).Range("A1").Select
    Selection.End(xlDown).Select
    Range("FM1048576").Select
    Selection.End(xlUp).Select
    ActiveCell.Offset(1, 0).Range("A1").Select
    'DICEMBRE
    Application.CutCopyMode = False
    ActiveSheet.Unprotect
    Sheets("DIC").Select
    Range("c3:P40").Select
    'ActiveSheet.Unprotect
    Application.CutCopyMode = False
    Selection.Copy
    Sheets("DBvendita").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
   
   
    ActiveWindow.SmallScroll Down:=16
    ActiveWindow.SmallScroll ToRight:=1
    ActiveCell.Offset(37, 14).Range("A1").Select
    Selection.End(xlDown).Select
    Range("GB1048576").Select
    Selection.End(xlUp).Select
    Application.CutCopyMode = False
    ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True
   
    '<<<<<COPIA I DATI in DBacquisti
    '
    '    GENNAIO
    Sheets("VERIFICA").Select
    Sheets("DBacquisti").Visible = True '<<<<<<<<<<<<<<scopre il DBacquisti
    Sheets("DBacquisti").Select
    ActiveSheet.Unprotect
    Sheets("GEN").Select
    Range("AH50:AJ53").Select
    Selection.Copy
    Sheets("DBacquisti").Select
    Range("C1").Select
    Selection.End(xlDown).Select
    Range("D1048576").Select
    Selection.End(xlUp).Select
    ActiveCell.Offset(1, 0).Range("A1").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    ActiveCell.Offset(3, 3).Range("A1").Select
    Selection.End(xlDown).Select
    Range("I1048576").Select
    Selection.End(xlUp).Select
    'FEBBRAIO
    Sheets("FEB").Select
    Range("AH50:AJ53").Select
    Application.CutCopyMode = False
    Selection.Copy
    Sheets("DBacquisti").Select
    ActiveCell.Offset(1, 0).Range("A1").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    ActiveCell.Offset(3, 3).Range("A1").Select
    Selection.End(xlDown).Select
    ActiveCell.Offset(0, 1).Range("A1").Select
    Selection.End(xlUp).Select
    'MARZO
    Sheets("MAR").Select
    Range("AH50:AJ53").Select
    Application.CutCopyMode = False
    Selection.Copy
    Sheets("DBacquisti").Select
    ActiveCell.Offset(1, 0).Range("A1").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    ActiveCell.Offset(3, 3).Range("A1").Select
    Selection.End(xlDown).Select
    Range("Q1048576").Select
    Selection.End(xlUp).Select
    'APRILE
    Sheets("APR").Select
    ActiveWindow.SmallScroll Down:=36
    Range("AH50:AJ53").Select
    Application.CutCopyMode = False
    Selection.Copy
    Sheets("DBacquisti").Select
    ActiveCell.Offset(1, 0).Range("A1").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    ActiveCell.Offset(3, 3).Range("A1").Select
    Selection.End(xlDown).Select
    Range("U1048576").Select
    Selection.End(xlUp).Select
    'MAGGIO
    Sheets("MAG").Select
    ActiveWindow.SmallScroll Down:=36
    Range("AH50:AJ53").Select
    Application.CutCopyMode = False
    Selection.Copy
    Sheets("DBacquisti").Select
    ActiveCell.Offset(1, 0).Range("A1").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    ActiveCell.Offset(3, 3).Range("A1").Select
    Selection.End(xlDown).Select
    Range("Y1048576").Select
    Selection.End(xlUp).Select
    'GIUGNO
    Sheets("GIU").Select
    ActiveWindow.SmallScroll Down:=36
    Range("AH50:AJ53").Select
    Application.CutCopyMode = False
    Selection.Copy
    Sheets("DBacquisti").Select
    ActiveCell.Offset(1, 0).Range("A1").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    ActiveCell.Offset(3, 3).Range("A1").Select
    Selection.End(xlDown).Select
    Range("AC1048576").Select
    Selection.End(xlUp).Select
    'LUGLIO
    Sheets("LUG").Select
    ActiveWindow.SmallScroll Down:=36
    Range("AH50:AJ53").Select
    Application.CutCopyMode = False
    Selection.Copy
    Sheets("DBacquisti").Select
    ActiveCell.Offset(1, 0).Range("A1").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    ActiveCell.Offset(3, 3).Range("A1").Select
    Selection.End(xlDown).Select
    Range("AG1048576").Select
    Selection.End(xlUp).Select
    'AGOSTO
    Sheets("AGO").Select
    ActiveWindow.SmallScroll Down:=36
    Range("AH50:AJ53").Select
    Application.CutCopyMode = False
    Selection.Copy
    Sheets("DBacquisti").Select
    ActiveCell.Offset(1, 0).Range("A1").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    ActiveCell.Offset(3, 3).Range("A1").Select
    Selection.End(xlDown).Select
    Range("AK1048576").Select
    Selection.End(xlUp).Select
    'SETTEMBRE
    Sheets("SET").Select
    ActiveWindow.SmallScroll Down:=36
    Range("AH50:AJ53").Select
    Application.CutCopyMode = False
    Selection.Copy
    Sheets("DBacquisti").Select
    ActiveCell.Offset(1, 0).Range("A1").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    ActiveCell.Offset(3, 3).Range("A1").Select
    Selection.End(xlDown).Select
    Range("AO1048576").Select
    Selection.End(xlUp).Select
    'OTTOBRE
    Sheets("OTT").Select
    ActiveWindow.SmallScroll Down:=36
    Range("AH50:AJ53").Select
    Application.CutCopyMode = False
    Selection.Copy
    Sheets("DBacquisti").Select
    ActiveCell.Offset(1, 0).Range("A1").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    ActiveCell.Offset(3, 3).Range("A1").Select
    Selection.End(xlDown).Select
    Range("AT1048576").Select
    Selection.End(xlUp).Select
    'NOVEMBRE
    Sheets("NOV").Select
    ActiveWindow.SmallScroll Down:=36
    Range("AH50:AJ53").Select
    Application.CutCopyMode = False
    Selection.Copy
    Sheets("DBacquisti").Select
    ActiveCell.Offset(1, 0).Range("A1").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    ActiveCell.Offset(3, 3).Range("A1").Select
    Selection.End(xlDown).Select
    Range("AY1048576").Select
    Selection.End(xlUp).Select
    'DICEMBRE
    Sheets("DIC").Select
    ActiveWindow.SmallScroll Down:=36
    Range("AH50:AJ53").Select
    Application.CutCopyMode = False
    Selection.Copy
    Sheets("DBacquisti").Select
    ActiveCell.Offset(1, 0).Range("A1").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    ActiveCell.Offset(3, 3).Range("A1").Select
    Selection.End(xlDown).Select
    Range("BD1048576").Select
    Selection.End(xlUp).Select
    '
    '
    '<<<CANCELLA I DATI dell'ANNO appena passato
    '
    '
    Sheets("DIC").Select
    ActiveWindow.SmallScroll Down:=3
    Range("G8:L38,N8:P38").Select
    Range("AH36").Select
    Application.CutCopyMode = False
    Selection.ClearContents
    Sheets("NOV").Select
    Range("G8:L37,N8:P37").Select
    Range("N37").Activate
    Selection.ClearContents
    Sheets("OTT").Select
    Range("G8:L38,N8:P38").Select
    Range("N38").Activate
    Selection.ClearContents
    Sheets("SET").Select
    Range("G8:L37,N8:P37").Select
    Range("N37").Activate
    Selection.ClearContents
    Sheets("AGO").Select
    Range("G8:L38,N8:P38").Select
    Range("N38").Activate
    Selection.ClearContents
    Sheets("LUG").Select
    Range("G8:L38,N8:P38").Select
    Range("N38").Activate
    Selection.ClearContents
    Sheets("GIU").Select
    Range("G8:L38,N8:P38").Select
    Range("N38").Activate
    Selection.ClearContents
    Sheets("MAG").Select
    Range("G8:L38,N8:P38").Select
    Range("N38").Activate
    Selection.ClearContents
    Sheets("APR").Select
    Range("G8:L37,N8:P37").Select
    Range("N37").Activate
    Selection.ClearContents
    Sheets("MAR").Select
    Range("G8:L38,N8:P38").Select
    Range("N38").Activate
    Selection.ClearContents
    Sheets("FEB").Select
    Range("G8:L38,N8:P38").Select
    Range("N38").Activate
    'Selection.ClearContents
    Sheets("GEN").Select
    ActiveWindow.SmallScroll Down:=-39
    Range("G8:L38,N8:P38").Select
    Range("N38").Activate
    Selection.ClearContents
    ActiveWindow.SmallScroll Down:=-6
    '
    '<<<<<<<<<<<<<RIPROTEGGE I FOGLI DI LAVORO
    ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True
    Range("G8").Select
    Sheets("FEB").Select
    ActiveWindow.SmallScroll Down:=-36
    ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True
    Range("G8").Select
    Sheets("MAR").Select
    ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True
    Range("G8").Select
    Sheets("APR").Select
    ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True
    Range("G8").Select
    Sheets("MAG").Select
    ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True
    Range("G8").Select
    Sheets("GIU").Select
    ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True
    Range("G8").Select
    Sheets("LUG").Select
    ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True
    Range("G8").Select
    Sheets("AGO").Select
    ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True
    Range("G8").Select
    Sheets("SET").Select
    ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True
    Range("G8").Select
    Sheets("OTT").Select
    ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True
    Range("G8").Select
    Sheets("NOV").Select
    ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True
    Range("G8").Select
    Sheets("DIC").Select
    ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True
    Range("L38").Select
    '
    Application.CutCopyMode = False
    ActiveSheet.Unprotect
    '<<<<<<<<<<nasconde il DBvendita
    ActiveWindow.ScrollWorkbookTabs Position:=xlFirst
   Sheets("DBvendita").Select
    ActiveWindow.SelectedSheets.Visible = Fal
     '<<<<<<<<<<nasconde il DBacquisti
    ActiveWindow.ScrollWorkbookTabs Position:=xlFirst
   Sheets("DBacquisti").Select
    ActiveWindow.SelectedSheets.Visible = Fal
    Sheets("GEN").Select '<<<<<<Si posiziona sulla cella G8 di gennaio
    Range("G8").Select
    ThisWorkbook.Save '<<<<<<<<Salva il file
    Exit Sub
    End If
End Sub


in riferimento alla condizione di un eventuale errore di lancio della macro non mi funziona Perche?
..
CopiaAnno Macro
MsgBox "Attenzione chiusura annuale Selezione nella cella AH36 ( Si O NO )"

If Sheets("DIC").Range("AH36") = "S" Then '<<<<<<<<<Condizione di conferma se salvare o non salvare
Call CopiaAnno
Else:
MsgBox ("Dati non Caricati ")
End If
Exit Sub


grazie per l'aiuto
Avatar utente
Zagor57
Utente Junior
 
Post: 75
Iscritto il: 04/05/15 19:35
Località: Massafra TA

Re: Macro copia i Valori da fogli per crearne uno pluriennal

Postdi Flash30005 » 05/07/15 23:30

Non può funzionare così
Codice: Seleziona tutto
Sub CopiaAnno()
'
' CopiaAnno Macro
MsgBox "Attenzione chiusura annuale Selezione nella cella  AH36  ( Si O NO )"
   
    If Sheets("DIC").Range("AH36") = "S" Then    '<<<<<<<<<Condizione di conferma se salvare o non salvare
    Call CopiaAnno   '<<<<<<<< se la condizione è soddisfatta entra in loop
    Else:
    MsgBox ("Dati non Caricati ")
    End If
  Exit Sub  '<<<<<<<< se la condizione non è soddisfatta esce dalla macro con questo Exit
'<<<<< e qui non ci arriverà mi la macro
'....

Ciao
Avatar utente
Flash30005
Moderatore
 
Post: 8517
Iscritto il: 27/09/07 11:44
Località: Roma +o-

Re: Macro copia i Valori da fogli per crearne uno pluriennal

Postdi Zagor57 » 06/07/15 11:56

Giusto quello che dici Flash30005
è prorio per questo che chiedevo il vostro aiuto
P.S. non so quasi nulla di programmazione .
Oltre a questo vorrei chederti un'altra cosa
nel foglio IMPOSTAZIONI nella cella combinata AD:AF c'è inserito l'anno
posso all'invio della macro prima di effettuare il salvataggio di aumentarmi di un numero l'anno ( es.adesso 2015 l'anno prossimo 2016)
dimenticavo grazie per l'interessamento
CIAO
Avatar utente
Zagor57
Utente Junior
 
Post: 75
Iscritto il: 04/05/15 19:35
Località: Massafra TA

Re: Macro copia i Valori da fogli per crearne uno pluriennal

Postdi Zagor57 » 06/07/15 13:11

nel foglio IMPOSTAZIONI nella cella combinata AD:AF c'è inserito l'anno

Scusa in una cella unita
Avatar utente
Zagor57
Utente Junior
 
Post: 75
Iscritto il: 04/05/15 19:35
Località: Massafra TA

Re: Macro copia i Valori da fogli per crearne uno pluriennal

Postdi Flash30005 » 06/07/15 13:22

Per poter fare qualcosa dovrei avere un file simile al tuo
Inoltre eviterei di cancellare l'anno precedente ma di salvarlo con un riferimento all'anno e poi prepararlo per l'anno nuovo etc.
Ma non so l'effettiva esigenza

ciao
Flash
Win10 + Office 2010 Ita
"Fotografica" al servizio dell'immagine
Avatar utente
Flash30005
Moderatore
 
Post: 8517
Iscritto il: 27/09/07 11:44
Località: Roma +o-

Re: Macro copia i Valori da fogli per crearne uno pluriennal

Postdi Zagor57 » 06/07/15 14:32

In effetti l'anno è stato già copiato nel foglio " DBvendita "
quello che vorrei fare a fine anno è.........:l'operatore non deve andare nel foglio impostazioni per cambiare l'anno come innanzi da cella unita .
dato che la macro al suo completamento salva il file vorrei prima che ciò avvenga, viene aumentato di un anno ripeto es:da 2015 a 2016 ecc.......
Avatar utente
Zagor57
Utente Junior
 
Post: 75
Iscritto il: 04/05/15 19:35
Località: Massafra TA

Re: Macro copia i Valori da fogli per crearne uno pluriennal

Postdi Zagor57 » 06/07/15 16:07

OK o risolto con un copia incolla questa e la parte di macro riferita al cambio numero dell'anno
Codice: Seleziona tutto
Sheets("DIC").Select '<<<<<<<<<<<<<<<<<<<<Cambia il numero dell'anno
    Sheets("IMPOSTAZIONI").Visible = True
  Sheets("IMPOSTAZIONI").Select
    ActiveSheet.Unprotect
    Range("AD49").Select
    Selection.Copy
    Range("AM49").Select
    ActiveSheet.Paste
    Range("AD49").Select
    Application.CutCopyMode = False
    Selection.ClearContents
    Range("BE49").Select
    Selection.Copy
    Range("AD49").Select

    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Application.CutCopyMode = False
    With Selection
        .HorizontalAlignment = xlCenter
        .VerticalAlignment = xlCenter
        .WrapText = False
        .Orientation = 0
        .AddIndent = False
        .IndentLevel = 0
        .ShrinkToFit = False
        .ReadingOrder = xlContext
        .MergeCells = False
    End With
    ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True
    Sheets("IMPOSTAZIONI").Select
    ActiveWindow.SelectedSheets.Visible = False
    ThisWorkbook.Save '<<<<<<<<Salva il file

Ora però vorrei risolvere la condizione del

Sub CopiaAnno()
'
' CopiaAnno Macro
MsgBox "Attenzione chiusura annuale Selezione nella cella AH36 ( Si O NO )"

If Sheets("DIC").Range("AH36") = "S" Then '<<<<<<<<<Condizione di conferma se salvare o non salvare
Call CopiaAnno
Else:
MsgBox ("Dati non Caricati ")
End If
Exit Sub


e qui credo di voler assolutamente il V O S T R O Aiutooooooooooooooooooooooooooooo :D

Grazie
Avatar utente
Zagor57
Utente Junior
 
Post: 75
Iscritto il: 04/05/15 19:35
Località: Massafra TA

Re: Macro copia i Valori da fogli per crearne uno pluriennal

Postdi Flash30005 » 06/07/15 16:44

Riguardo alle righe che riproduci penso che tu debba fare così
Codice: Seleziona tutto
Sub CopiaAnno()
'
' CopiaAnno Macro
MsgBox "Attenzione chiusura annuale Selezione nella cella AH36 ( Si O NO )"  '<<< questo messaggio lo vedo inutile

 If Ucase(Sheets("DIC").Range("AH36")) <> "S" Then '<<<<<<<<<Condizione di conferma se salvare o non salvare
  MsgBox ("Dati non Caricati ")
Exit Sub
 End If
'....
'...
'... continua il resto della macro
 


Ciao
Flash
Win10 + Office 2010 Ita
"Fotografica" al servizio dell'immagine
Avatar utente
Flash30005
Moderatore
 
Post: 8517
Iscritto il: 27/09/07 11:44
Località: Roma +o-

Re: Macro copia i Valori da fogli per crearne uno pluriennal

Postdi Zagor57 » 06/07/15 17:09

NON va
Avatar utente
Zagor57
Utente Junior
 
Post: 75
Iscritto il: 04/05/15 19:35
Località: Massafra TA

Re: Macro copia i Valori da fogli per crearne uno pluriennal

Postdi Zagor57 » 06/07/15 17:14

Falso era che nella condizione era <S> invece nella risposta è <SI>
OK ora è tutto perfetto
Grazie Flash

Ciao
Avatar utente
Zagor57
Utente Junior
 
Post: 75
Iscritto il: 04/05/15 19:35
Località: Massafra TA


Torna a Applicazioni Office Windows


Topic correlati a "Macro copia i Valori da fogli per crearne uno pluriennale":


Chi c’è in linea

Visitano il forum: Nessuno e 43 ospiti