ich habe einen Code geschrieben der eigentlich funktionierte. Seit ein paar Tagen kommt allerdings die folgende Fehlermeldung wobei ich eure Hilfe benötige:
"Run-time error '-2147352571 (80020005)':
Could not set the Value property. Type mismatch.
Er stoppt immer an der Stelle: TextBox1.Value = td.Cells(vntRow,2)
Er findet aber auch für vntRow einen Wert z.B. 3
Ich hoffe ihr könnt mir helfen. Falls eine Datei benötigt wird, stelle ich gerne eine zur Verfügung.
Viele Grüße Dennis
Private Sub UserForm_Activate() 'Userform mit vorhandenen Werten ausfüllen
Dim tp As Worksheet, tv As Worksheet
Dim vntRow
Set tp = Worksheets("Overview")
Set td = Worksheets("Daten")
Call UnProtectAll
Application.DisplayAlerts = False
With tp
If .Cells(8, 3).Value "" Then
vntRow = Application.Match(.Cells(8, 3).Value, td.Columns(1), 0)
If Not IsError(vntRow) Then
TextBox1.Value = td.Cells(vntRow, 2)
TextBox2.Value = td.Cells(vntRow, 1)
TextBox3.Value = td.Cells(vntRow, 11)
TextBox4.Value = td.Cells(vntRow, 14)
TextBox5.Value = td.Cells(vntRow, 20)
TextBox6.Value = td.Cells(vntRow, 29)
TextBox7.Value = td.Cells(vntRow, 15)
TextBox8.Value = td.Cells(vntRow, 16)
TextBox9.Value = td.Cells(vntRow, 13)
TextBox10.Value = td.Cells(vntRow, 21)
TextBox11.Value = td.Cells(vntRow, 22)
TextBox12.Value = td.Cells(vntRow, 23)
TextBox13.Value = td.Cells(vntRow, 24)
TextBox14.Value = td.Cells(vntRow, 25)
TextBox15.Value = td.Cells(vntRow, 26)
TextBox16.Value = td.Cells(vntRow, 28)
TextBox17.Value = td.Cells(vntRow, 27)
TextBox18.Value = td.Cells(vntRow, 31)
If td.Cells(vntRow, 17) = "Kartonage" Then ' Materialart wird gespeichert
t = 1
ElseIf td.Cells(vntRow, 17) = "Füllmaterial" Then
t = 2
ElseIf td.Cells(vntRow, 17) = "Sonstiges" Then
t = 3
End If
If t = 1 Then
Kartonage.Value = True
ElseIf t = 2 Then
Füllmaterial.Value = True
ElseIf t = 3 Then
Sonstiges.Value = True
End If
If td.Cells(vntRow, 32).Value = "aktiv" Then ' Anzeige ob das Material noch aktiv ist oder nicht
Aktiv.Value = True
Else: NichtAktiv.Value = True
End If
End If
End If
End With
Call ProtectAll
End Sub