Als Antwort auf diesen Beitrag
hier noch der Code:
Sub Update()
Dim Pfad, vImp$, arrA(), arrB(), arrC(), arrD(), arrE, arrF(), dateUp As Date
Pfad = Application.GetOpenFilename("Excel Files (*.xlsx), *.xls", , "XLSx", "Auswahl", _
False)
If TypeName(Pfad) Like "Boolean" Then
MsgBox "Keine Datei gewählt!", vbInformation
Exit Sub
Else
Application.EnableEvents = False
Workbooks.Open Pfad
vImp = Right$(Pfad, Len(Pfad) - InStrRev(Pfad, "\"))
With Workbooks(vImp).Sheets("Tabelle1")
dateUp = .Range("B1") 'Updatestand
arrA = .Range("B66:C72").Value 'Baukostenindes usw.
arrB = .Range("D5:E5").Value 'Beitragssätze
arrC = .Range("D19:F20").Value 'Glas
arrD = .Range("F33:H35").Value 'HuG
.Range("F51:F53,F56:F58").NumberFormat = "General"
arrE = .Range("F51:H53").Value 'GSH oberirdisch
arrF = .Range("F56:H58").Value 'GSH unterirdisch
Application.DisplayAlerts = False
Application.EnableEvents = True
Workbooks(vImp).Close
Application.DisplayAlerts = True
End With
End If
With Tabelle5
.Unprotect Password:="Test"
.Cells(1, 2) = dateUp
.Cells(3, 2).Resize(5, 2) = arrA
.Protect Password:="Test"
End With
With Tabelle1
.Unprotect Password:="Test"
.Cells(4, 2).Resize(1, 2) = arrB
.Cells(7, 4).Resize(2, 3) = arrC
.Cells(13, 7).Resize(3, 3) = arrD
.Cells(20, 7).Resize(3, 2) = arrE
.Cells(25, 7).Resize(3, 2) = arrF
.Protect Password:="Test"
End With
End Sub
eine weitere zwingende Änderung ist die Variable Pfad. Diese ist natürlich Variant und nicht String, da sonst bei Abbruch Boolean nicht ausgewertet werden kann.
Gruß Uwe