Private Sub CommandButton28_Click()
Dim wk1 As ThisWorkbook: Set wk1 = ThisWorkbook
Workbooks.Open ("C:UsersLelloDesktopfatturazione.xlsm") ' da cambiare
Dim wk2 As Workbook: Set wk2 = Workbooks("fatturazione.xlsm") ' da cambiare casomai
Dim sh2 As Worksheet: Set sh2 = wk2.Worksheets("Archivio Generale")
uriga = sh2.Range("A" & Rows.Count).End(xlUp).Row + 1
wk1.Activate
Label12 = "Attendere prego....."
Dim msg, Style, title, response, MyString, rr As Long
msg = "Vuoi Registrare in archivio tutte le Fatture ? "
Style = vbYesNo + vbExclamation + vbDefaultButton2
title = "ATTENZIONE !"
response = MsgBox(msg, Style, title)
If response = vbYes Then
MyString = "Yes"
For Each sh In wk1.Sheets
With sh
If .Index > 2 Then
irow = 4 ' inizia a scrivere dalla riga 4
While Sheets("Archivio Fatture").Cells(irow, 1) <> ""
irow = irow + 1 '+ 1
Wend
Sheets("Archivio Fatture").Cells(irow, 1) = .[C13] 'Cod. cliente
sh2.Cells(uriga, 1) = .[C13]
Sheets("Archivio Fatture").Cells(irow, 2) = .[F6] 'Rag. Sociale
sh2.Cells(uriga, 2) = .[F6]
Sheets("Archivio Fatture").Cells(irow, 3) = .[F7] 'Indirizzo cliente
sh2.Cells(uriga, 3) = .[F7]
Sheets("Archivio Fatture").Cells(irow, 4) = .[F8] 'Cap
sh2.Cells(uriga, 2) = .[F8]
Sheets("Archivio Fatture").Cells(irow, 5) = .[G8] 'Città
sh2.Cells(uriga, 2) = .[G8]
Sheets("Archivio Fatture").Cells(irow, 6) = .[G9] 'P. Iva
sh2.Cells(uriga, 2) = .[G9]
Sheets("Archivio Fatture").Cells(irow, 7) = .[G10] 'Codice Fiscale
sh2.Cells(uriga, 2) = .[G10]
Sheets("Archivio Fatture").Cells(irow, 8) = .[I3] 'Data Emissione Fattura
sh2.Cells(uriga, 2) = .[I3]
Sheets("Archivio Fatture").Cells(irow, 9) = .[G3] 'N. Fattura
sh2.Cells(uriga, 2) = .[G3]
Sheets("Archivio Fatture").Cells(irow, 10) = .[C15] 'Periodo dal
sh2.Cells(uriga, 2) = .[C15]
Sheets("Archivio Fatture").Cells(irow, 11) = .[E15] 'Periodo al
sh2.Cells(uriga, 2) = .[E15]
Sheets("Archivio Fatture").Cells(irow, 12) = .[B18] 'Descrizione
sh2.Cells(uriga, 2) = .[B18]
Sheets("Archivio Fatture").Cells(irow, 13) = .[B20] 'Indirizzo
sh2.Cells(uriga, 2) = .[B20]
Sheets("Archivio Fatture").Cells(irow, 14) = .[B21] 'Cap
sh2.Cells(uriga, 2) = .[B21]
Sheets("Archivio Fatture").Cells(irow, 15) = .[C21] 'Città
sh2.Cells(uriga, 2) = .[C21]
Sheets("Archivio Fatture").Cells(irow, 16) = .[E41] 'Imponibile
sh2.Cells(uriga, 2) = .[E41]
Sheets("Archivio Fatture").Cells(irow, 17) = .[G41] 'Iva
sh2.Cells(uriga, 2) = .[G41]
Sheets("Archivio Fatture").Cells(irow, 18) = .[I41] 'Totale
sh2.Cells(uriga, 2) = .[I41]
Sheets("Archivio Fatture").Cells(irow, 19) = .[H40] 'Percentuale iva %
sh2.Cells(uriga, 2) = .[H40]
Sheets("Archivio Fatture").Cells(irow, 20) = .[B22] 'Descrizione 2
sh2.Cells(uriga, 2) = .[B22]
Sheets("Archivio Fatture").Cells(irow, 21) = .[B24] 'Indirizzo 2
sh2.Cells(uriga, 2) = .[B24]
Sheets("Archivio Fatture").Cells(irow, 22) = .[B25] ' Cap 2
sh2.Cells(uriga, 2) = .[B25]
Sheets("Archivio Fatture").Cells(irow, 23) = .[C25] 'Città 2
sh2.Cells(uriga, 2) = .[C25]
Sheets("Archivio Fatture").Cells(irow, 24) = .[B26] 'Descrizione 3
sh2.Cells(uriga, 2) = .[B26]
Sheets("Archivio Fatture").Cells(irow, 25) = .[B28] 'Indirizzo 3
sh2.Cells(uriga, 2) = .[B28]
Sheets("Archivio Fatture").Cells(irow, 26) = .[B29] 'Cap 3
sh2.Cells(uriga, 2) = .[B29]
Sheets("Archivio Fatture").Cells(irow, 27) = .[C29] 'Città 3
sh2.Cells(uriga, 2) = .[C29]
Sheets("Archivio Fatture").Cells(irow, 28) = .[B30] 'Descrizione 4
sh2.Cells(uriga, 2) = .[B30]
Sheets("Archivio Fatture").Cells(irow, 29) = .[B32] 'Indirizzo 4
sh2.Cells(uriga, 2) = .[B32]
Sheets("Archivio Fatture").Cells(irow, 30) = .[B33] 'Cap 4
sh2.Cells(uriga, 2) = .[B33]
Sheets("Archivio Fatture").Cells(irow, 31) = .[C33] 'Città 4
sh2.Cells(uriga, 2) = .[C33]
Sheets("Archivio Fatture").Cells(irow, 32) = .[B34] 'Descrizione 5
sh2.Cells(uriga, 2) = .[B34]
Sheets("Archivio Fatture").Cells(irow, 33) = .[B36] 'Indirizzo 5
sh2.Cells(uriga, 2) = .[B36]
Sheets("Archivio Fatture").Cells(irow, 34) = .[B37] 'Cap 5
sh2.Cells(uriga, 2) = .[B37]
Sheets("Archivio Fatture").Cells(irow, 35) = .[C37] 'Città 5
sh2.Cells(uriga, 2) = .[C37]
Sheets("Archivio Fatture").Cells(irow, 36) = .[B38] 'Descrizione 6
sh2.Cells(uriga, 2) = .[B38]
Sheets("Archivio Fatture").Cells(irow, 37) = .[C14] 'Codice Esattore
sh2.Cells(uriga, 2) = .[C14]
uriga = uriga + 1
End If
End With
Next
wk2.Save
wk2.Close
Label12 = ""
MsgBox "Tutte le Fatture sono state registrate...", vbInformation, ("Fatture Registrate...")
CommandButton28.BackColor = 65535 '<--- di colore giallo
Else
MyString = "No"
Label12 = ""
End If
Set wk1 = Nothing
Set wk2 = Nothing
Set sh2 = Nothing
End Sub |