
Sub ARCHIVIARIBA()
Dim X, Rr, Rg As Object
Ur = Sheets("Fatture").Range("A" & Rows.Count).End(xlUp).Row
Application.ScreenUpdating = False
Application.DisplayAlerts = False
For X = 7 To Ur
'''''''''''''''''''''''''''''''''''''''''''''''''''''''
If Sheets("Fatture").Cells(X, 2) = "DA EMETTERE" And _
Sheets("Fatture").Cells(X, 7) = "RICEVUTA BANCARIA" Then ''inizio controllo
Set Rg = Sheets("Fatture").Cells(X, 1)
Rr = Rg.Row
Sheets("MasterRIBA").Cells(17, 8) = Sheets("Fatture").Cells(1, 1) + 1
Sheets("MasterRIBA").Cells(17, 10) = Sheets("Fatture").Cells(X, 5)
Sheets("MasterRIBA").Cells(18, 5) = Sheets("Fatture").Cells(X, 1)
Sheets("MasterRIBA").Cells(19, 5) = Sheets("Fatture").Cells(X, 19)
Sheets("MasterRIBA").Cells(20, 5) = Sheets("Fatture").Cells(X, 20)
Sheets("MasterRIBA").Cells(21, 6) = Sheets("Fatture").Cells(X, 21)
Sheets("MasterRIBA").Cells(25, 2) = Sheets("Fatture").Cells(X, 9)
Sheets("MasterRIBA").Cells(25, 10) = Sheets("Fatture").Cells(X, 11)
Sheets("MasterRIBA").Cells(27, 10) = Sheets("Fatture").Cells(X, 12)
Sheets("MasterRIBA").Cells(28, 10) = Sheets("Fatture").Cells(X, 13)
Sheets("MasterRIBA").Cells(29, 10) = Sheets("Fatture").Cells(X, 14)
Sheets("MasterRIBA").Cells(30, 10) = Sheets("Fatture").Cells(X, 15)
Sheets("MasterRIBA").Cells(35, 5) = Sheets("Fatture").Cells(X, 16)
Sheets("MasterRIBA").Cells(34, 5) = Sheets("Fatture").Cells(X, 7)
Sheets("MasterRIBA").Cells(32, 5) = Sheets("Fatture").Cells(X, 22)
Sheets("MasterRIBA").Cells(33, 6) = Sheets("Fatture").Cells(X, 18)
Sheets("Fatture").Cells(1, 1) = Sheets("Fatture").Cells(1, 1) + 1
Sheets("Fatture").Cells(2, 9).Copy
Sheets("Fatture").Cells(X, 2).PasteSpecial
Sheets("Fatture").Cells(X, 3) = Sheets("Fatture").Cells(1, 1)
' salvo PDF
Dim strFile As String
Dim PERCORSO As String
PERCORSO = ThisWorkbook.Path & "Fatture-Stampate"
Set ws = Sheets("MasterRIBA")
strFile = Sheets("Fatture").Cells(1, 1) & "_" & "2016" & "-" & Sheets("MasterRIBA").Cells(18, 5) & " (" & Sheets("MasterRIBA").Cells(25, 2) & ")" & ".pdf"
Sheets("MasterRIBA").ExportAsFixedFormat Type:=xlTypePDF, Filename:=PERCORSO & strFile, Quality:= _
xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas:=False, _
OpenAfterPublish:=False
End If ''termina (If)
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Stampa
'inserire codice stampa
' non cancello nulla dato che alla prossima viene ricalcolato
Next X
Fine:
Application.ScreenUpdating = True
Application.DisplayAlerts = True
MsgBox "CREATI File PDF"
End Sub |
Sub ARCHIVIA()
Dim X, Rr, I, Fat, Rg As Object
Ur = Sheets("Fatture").Range("A" & Rows.Count).End(xlUp).Row
Application.ScreenUpdating = False
Application.DisplayAlerts = False
I = 0
If Application.Max(Sheets("Master").Range("C:C")) + 1 <> Sheets("Fatture").Cells(1, 1) Then
Fat = InputBox("inserisci il numero fattura da stampare/salvare", , 0)
If Fat = "" Or Fat = 0 Then GoTo Fine
End If
For X = 7 To Ur
Fat = Sheets("Fatture").Cells(1, 1).Value
If Sheets("Fatture").Cells(X, 2) = "DA EMETTERE" Then
Set Rg = Sheets("Fatture").Columns("AB").Find(Sheets("Fatture").Cells(X, 1), LookIn:=xlValues, LookAt:=xlWhole)
If Rg Is Nothing Then
MsgBox "nessuna corrispondenza d'azienda"
GoTo Fine
Else
Rr = Rg.Row
End If
Sheets("Master").Cells(17, 8) = Fat
Sheets("Master").Cells(17, 9) = Date
Sheets("Master").Cells(18, 4) = Sheets("Fatture").Cells(Rr, 28)
Sheets("Master").Cells(19, 4) = Sheets("Fatture").Cells(Rr, 30)
Sheets("Master").Cells(20, 4) = Sheets("Fatture").Cells(Rr, 32)
Sheets("Master").Cells(21, 5) = Sheets("Fatture").Cells(Rr, 33)
Sheets("Master").Cells(27, 2) = Sheets("Fatture").Cells(X, 9) 'intendevo questa
Sheets("Master").Cells(27, 9) = Sheets("Fatture").Cells(X, 11)
Sheets("Master").Cells(31, 9) = Sheets("Fatture").Cells(X, 11)
Sheets("Master").Cells(33, 9) = Sheets("Fatture").Cells(X, 11) + Sheets("Master").Cells(32, 9)
Sheets("Master").Cells(38, 5) = Sheets("Fatture").Cells(Rr, 33)
Sheets("Master").Cells(39, 6) = Sheets("Fatture").Cells(Rr, 29)
Sheets("Master").Cells(40, 5) = Sheets("Fatture").Cells(X, 7)
Sheets("Master").Cells(41, 5) = Sheets("Fatture").Cells(X, 5)
Sheets("Fatture").Cells(2, 9).Copy
Sheets("Fatture").Cells(X, 2).PasteSpecial
Sheets("Fatture").Cells(X, 3) = Fat
' salvo PDF
Dim strFile As String
Dim PERCORSO As String
PERCORSO = ThisWorkbook.Path & "PDF"
Sheets("Master").Activate
strFile = Fat & "_" & Format(Now(), "yyyy-mm-dd\_hh-mm") & ".pdf"
'strFile = Fat & "_" & Format(Date, "yyyy-mm-dd") & ".pdf"
Sheets("Master").ExportAsFixedFormat Type:=xlTypePDF, Filename:=PERCORSO & strFile, Quality:= _
xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas:=False, _
OpenAfterPublish:=False
' Stampa dovrebbe essere cosi (EDIT dovrebbe essere cosi)
ActiveWindow.SelectedSheets.PrintOut Copies:=1
Sheets("Master").Range("H17,I17,D18,D19:F19,D20:F20,E21:F21,B27:H28,I27:I28,I31,I33,E38,F39,E40:I40,E40:I40,E41:I41").ClearContents
I = I + 1
End If
Next X
MsgBox "fatto, " & I & " fatture salcate/stampate"
Fine:
Application.ScreenUpdating = True
Application.DisplayAlerts = True
End Sub
|
