Hallo,
ich habe ein weiteres Problem in meiner Programmierung.
Ich weis nicht wie ich am besten folgende Formeln in VBA implementieren kann.
Am Ende der Programmierung habe ich mich bisschen daran versucht, allerdings komme ich nicht weiter.
1. Formel in Zelle V2: =K2-SVERWEIS('01-2020'!C2;'01-2020'!C2:K80;2;FALSCH)
2. Formelin Zelle U2: =K2*R2
3. Formel in Zelle W2: =RUNDEN(SVERWEIS('02-2020'!A2;'Mietpreisliste aktuell'!$A$1:$H$480;8;FALSCH);4)
4. Formel in Zelle X2: =K2*W2
5. Formel in Zelle Y2: =WENN(R2=RUNDEN(W2;4);"OK";"Preis stimmt nicht")
6. Formel in Zelle Z2: =WENN(U2=X2;"OK";"Preis stimmt nicht")
Diese Formeln sollen auch für die weiteren/darauffolgenden Zellen gelten.
Sub Datenimport()
'Daten importieren
Dim strInvoicePeriod As String
Dim File As String
Dim wkb As Excel.Workbook
'Define name of new Tab
strInvoicePeriod = InputBox("Which Invoice Period shall be imported? (e.g. 02-2020")
Do Until strInvoicePeriod <> "" And Len(strInvoicePeriod) = 7
strInvoicePeriod = InputBox("Please insert the following data! Which Invoice Period shall be imported? (e.g. 02-2020")
Loop
'select promaintain invoice file
File = Application.GetOpenFilename()
'copy invoice sheet from promaintain file into this workbook
On Error GoTo ErrHandler
Application.ScreenUpdating = False
Set wkb = Workbooks.Open(File)
wkb.Sheets(1).Copy After:=ThisWorkbook.Sheets(ThisWorkbook.Sheets.Count)
ThisWorkbook.Sheets(ThisWorkbook.Sheets.Count).Name = strInvoicePeriod
wkb.Close False
Application.ScreenUpdating = True
lnglstSP = ThisWorkbook.Sheets(strInvoicePeriod).Cells(1, Columns.Count).End(xlToLeft).Column
ThisWorkbook.Sheets(strInvoicePeriod).Cells(1, lnglstSP).Offset(0, 1) = "Mengendifferenz zur letzten Rechnung"
ThisWorkbook.Sheets(strInvoicePeriod).Cells(1, lnglstSP).Offset(0, 2) = "Preis aus Materialpreisliste pro Tag"
ThisWorkbook.Sheets(strInvoicePeriod).Cells(1, lnglstSP).Offset(0, 3) = "Gesamtpreis aus Materialpreisliste pro Tag"
ThisWorkbook.Sheets(strInvoicePeriod).Cells(1, lnglstSP).Offset(0, 4) = "Stimmen Einzelpreise pro Tag aus Mietpreisliste und Rechnung überein?"
ThisWorkbook.Sheets(strInvoicePeriod).Cells(1, lnglstSP).Offset(0, 5) = "Stimmen Gesamtpreise überein?"
'ZeilenUndSpaltenZahl
MsgBox ActiveSheet.Cells.UsedRange & " Zeilen " & _
ActiveSheet.Cells.UsedRange & " Spalten."
ErrHandler:
Application.EnableEvents = True
Application.ScreenUpdating = True
End Sub
Public Sub FormelnSchreiben1()
Dim oBlatt As Worksheet
Set oBlatt = ThisWorkbook.Worksheets("Tabelle1") 'Tabellennamen gg. anpassen
With oBlatt
.Range("u2").FormulaLocal = "=Product(K2*R2)"
.Range("u3").FormulaLocal = "=Product(K3*R3)"
End With
Set oBlatt = Nothing
End Sub
|