Sub Macro2()
Dim wbFrom As Workbook, wbTo As Workbook
Dim wsF As Worksheet, wsT As Worksheet
Dim x As Long
Dim strFile As String
With Application.FileDialog(msoFileDialogOpen)
.InitialFileName = "C:UsersstefanoDocumentsMy Dropboxdativendita*.xls*"
.Title = "Seleziona il File"
.AllowMultiSelect = False
.Show
If .SelectedItems.Count = 0 Then Exit Sub
strFile = .SelectedItems(1)
End With
If strFile = "" Then GoTo Uscita
Set wbTo = ThisWorkbook
Set wsT = wbTo.Worksheets("articoli")
Set wbFrom = Application.Workbooks.Open(strFile)
Set wsF = wbFrom.Worksheets(1)
With wsT
x = .Range("A" & .Rows.Count).End(xlUp).Row
.Range("A2:F" & x).ClearContents
End With
With wsF
x = .Range("A" & .Rows.Count).End(xlUp).Row
.Range("A2:F" & x).Copy wsT.Range("A2")
wsT.Range("A2:F" & x) = wsT.Range("A2:F" & x).Value
.Parent.Close vbNo
End With
Set wbTo = Nothing
Set wsT = Nothing
Set wbFrom = Nothing
Set wsF = Nothing
Uscita:
ActiveSheet.PivotTables("Tabella_pivot1").PivotCache.Refresh
End Sub
Sub Macro12()
'
' Macro12 Macro
'
'
Range("Tabella1[[#Headers],[codice]]").Select
Selection.End(xlDown).Select
ActiveCell.Offset(1, 0).Range("Tabella1[[#Headers],[codice]]").Select
Selection.End(xlToRight).Select
Range(Selection, Selection.End(xlToRight)).Select
Range(Selection, Selection.End(xlDown)).Select
Selection.ClearContents
ActiveSheet.ListObjects("Tabella1").Resize Range("A2").CurrentRegion
End Sub
|