VBA - Formula.Local
19.04.2021 17:06:35
excelliebe
leider funktioniert mein Code nicht - Fehlercode: Argumenttyp ByRef unverträglich; markiert wird das erste Date1
Sub Formel()
Dim BestellmFormel As String
Dim Date1 As String
Dim Date4 As String
Dim letztZeile As Integer
letztZeile = Sheets("Nfr.").Cells(Rows.Count, "A").End(xlUp).Row
Date1 = Sheets("Nfr.").Cells(3, SpalteQTY.Column).Offset(, 1).Column
Date4 = Sheets("Nfr.").Cells(3, SpalteQTY.Column).Offset(, 4).Column
Dim SpalteQTY As Range
On Error Resume Next
Set SpalteQTY = Sheets("Nfr.").Rows(3).Find(what:="QTY", LookIn:=xlValues, lookat:=xlWhole)
On Error GoTo 0
BestellmFormel = "=INDEX(Nfr.!" & Buchstaben1(Date1) & "$4:" & Buchstaben4(Date4) & letztZeile & ";XVERGLEICH(Import!A2& _
Import!B2&Import!C2;Nfr.!$R$4:$R" & letztZeile & ");XVERGLEICH(Import!F2; Nfr.!" & Buchstaben1(Date1) & "$4:" & Buchstaben4(Date4) & letztZeile & "))"
Range("G2:G" & Cells(Rows.Count, "A").End(xlUp).Row).FormulaLocal = BestellmFormel
End Sub
Public Function Buchstaben1(Date1 As Long) As String
Buchstaben = Split(Cells(3, Date1).Address, "$")(1)
End Function
Public Function Buchstaben4(Date4 As Long) As String
Buchstaben = Split(Cells(3, Date4).Address, "$")(1)
End Function
Jemand eine Idee für das Problem? Viele Grüße und danke im Voraus :)