Salve, succede solo con questa macro in particolare: se la lancio manualmente da ALT+F8-ESEGUI o dall'editor di visual basic non ho problemi e funziona. Se invece imposto i tasti rapidi, la funzione non viene eseguita. Ho già provato a cambiare combinazioni di tasti...nulla.
Non ho nessun esito ne nel file esterno, ne come messaggio finale.
Sub IFRS16_new(dimmi As String)
'
' Macro per creazione file IFRS16 SEDI.xlsm
' copia tutte le filiali con canoni attivi o dismessi e filtra le colonne
' TASTO rapido CTRL+UP+K (non esegue lo script)
' Farlo partire con ALT+F8 ed ESEGUI...comandi rapidi da esito diverso, e non modifica il file.
'
Application.ScreenUpdating = False
Dir\_attuale = ActiveWorkbook.Path
' Pulizia
Workbooks.Open Filename:= \_
"X:\FACILITY\IFRS16 SEDI.xlsm"
Sheets("SEDI").Select
Rows("2:5000").Select
Selection.Delete Shift:=xlUp
Workbooks.Open Filename:= \_
Dir\_attuale & "\GESTIONE SEDI.xlsm"
Windows("GESTIONE SEDI.xlsm").Activate
Sheets("SEDI").Select
ActiveSheet.Unprotect
Rows("6:6").Select
Selection.AutoFilter
Selection.AutoFilter
UR\_Fac = Cells(Rows.Count, "A").End(xlUp).Row
UC\_Fac = Cells(6, Cells.Columns.Count).End(xlToLeft).Column
' Elaborazione
Windows("IFRS16 SEDI.xlsm").Activate
Sheets("SEDI").Select
UC\_Ifrs = Cells(1, Cells.Columns.Count).End(xlToLeft).Column
For i = 1 To UC\_Ifrs
Windows("IFRS16 SEDI.xlsm").Activate
Etichetta = Cells(1, i).Value
Windows("GESTIONE SEDI.xlsm").Activate
Trovato = False
For j = 1 To UC\_Fac
Eti\_Fac = Cells(6, j).Value
If ((Eti\_Fac = Etichetta) And (Trovato = False)) Then
Trovato = True
Range(Cells(6, j), Cells(UR\_Fac, j)).Select
Selection.Copy
Windows("IFRS16 SEDI.xlsm").Activate
Cells(1, i).Select
Application.WindowState = xlMaximized
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks \_
:=False, Transpose:=False
Windows("GESTIONE SEDI.xlsm").Activate
End If
Next j
Next i
'Chiude in modo trasparente il file originale( se macro lanciata dal file di destinazione)
'Application.DisplayAlerts = False
'Windows("GESTIONE SEDI.xlsm").Activate
'ActiveWorkbook.Close
'Application.DisplayAlerts = True
' Si eliminano le righe inutili
UR\_Ifrs = Cells(Rows.Count, "A").End(xlUp).Row
Windows("IFRS16 SEDI.xlsm").Activate
Columns("H:H").Select
ActiveSheet.Range("$A$1:$Z$" & UR\_Ifrs).AutoFilter Field:=8, Criteria1:=Array( \_
"CHIUSA", "IN FASE DI RICERCA", "SUBLOCAZIONE ATTIVA"), Operator:= \_
xlFilterValues
Rows("2:" & UR\_Ifrs).Select
Selection.Delete Shift:=xlUp
ActiveSheet.Range("$A$1:$Z$" & UR\_Ifrs).AutoFilter Field:=8
UR\_Ifrs = Cells(Rows.Count, "A").End(xlUp).Row
ActiveSheet.Range("$A$1:$Z$" & UR\_Ifrs).AutoFilter Field:=9, Criteria1:=Array( \_
"PROPRIETA'", "LEASING"), Operator:=xlFilterValues
Rows("2:" & UR\_Ifrs).Select
Selection.Delete Shift:=xlUp
ActiveSheet.Range("$A$1:$Z$" & UR\_Ifrs).AutoFilter Field:=9
Windows("IFRS16 SEDI.xlsm").Activate
'Formatta la data delle colonne che manca
Range("J:J,P:P,Q:Q,T:T,U:U").Select
'Range("U1").Activate
Selection.NumberFormat = "m/d/yyyy"
'seleziona tutto e ridimensiona le colenne automaticamente
Cells.Select
Cells.EntireColumn.AutoFit
Columns("P:P").Select
Selection.NumberFormat = "m/d/yyyy"
Range("A1").Select
Windows("IFRS16 SEDI.xlsm").Close (True)
'If ThisWorkbook.Saved = False Then
' ThisWorkbook.Save
'End If
dimmi = MsgBox("File creato", vbInformation, "Creare file IFRS16 SEDI.xlsm")
End Sub