Sub Carica_Dati()
Dim Rg As Object, R As Long, Nome As String, Path As String, Mese As String, Wk As Workbook
Mese = InputBox("digitare un mese?", , 0)
If Mese = "" Then Exit Sub
Dim Sh1 As Worksheet: Set Sh1 = Worksheets("MESE DA CALCOLARE") ' da cambiare casomai
Path = ThisWorkbook.Path & ""
Nome = "Database2.xls" ' da cambiare casomai
Set Wk = Application.Workbooks.Open(Path & Nome, 3, , , Password:="lello", WriteResPassword:="lello") 'lello...Modificare le due password
Dim Sh2 As Worksheet: Set Sh2 = Wk.Worksheets("RIASSUNTO ANNUALE") ' da cambiare casomai
Set Rg = Sh2.Range("A:A").Find(Mese, LookIn:=xlValues, LookAt:=xlWhole)
If Not Rg Is Nothing Then
R = Rg.Row
Sh2.Range(Sh2.Cells(R, 1), Sh2.Cells(R + 22, 1 + 31)).Copy
Sh1.Range("A1").PasteSpecial Paste:=xlPasteAll, Operation:=xlNone, SkipBlanks:=False, Transpose:=False
Application.DisplayAlerts = False
Windows("DATABASE2.xls").Close
Application.DisplayAlerts = True
End If
Set Wk = Nothing
Set Sh2 = Nothing
Set Sh1 = Nothing
Set Rg = Nothing
End Sub |