Ciao,
utilizzando questo codice riesco a far aprire una finestra dove mi si chiede di selezionare un determinato file, per poi incollarlo nel mio file e aggiornare la pivot, tutto tramite macro.
Quello che vorrei è che il file venisse cercato automaticamente in tutte le sottocartelle, partendo dalla posizione del mio file.
Sub Macro1()
Dim fDialog As Office.FileDialog
Set fDialog = Application.FileDialog(msoFileDialogFilePicker)
With fDialog
.AllowMultiSelect = False
.Title = "INSERISCI FILE 1"
.InitialFileName = ThisWorkbook.Path & "\Doc"
If .Show = -1 Then
For Each cavo In .SelectedItems
FileDaAprire = cavo
Next
Else
MsgBox "Operazione annullata!", vbInformation
Exit Sub
End If
End With
Application.Workbooks.Open (FileDaAprire)
Range("A2:G2").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Copy
Windows("AUTOMATICO.xlsm").Activate
Sheets("file_1").Select
Range("A2").Select
ActiveSheet.Paste
Range("H2").Select
Application.CutCopyMode = False
ActiveCell.FormulaR1C1 = "=RC[-1]*1.1"
Range("H2").Select
Selection.AutoFill Destination:=Range("H2:H534")
Range("H2:H534").Select
ActiveWindow.SmallScroll Down:=54
Sheets("file_1").Select
ActiveWindow.SmallScroll Down:=-78
Range("K9").Select
ActiveSheet.PivotTables("Tabella pivot3").PivotCache.Refresh
Application.Workbooks.Open (FileDaAprire)
ActiveWindow.Close
End Sub
grazie mille in anticipo