2 Application.Match
15.07.2024 16:00:57
Excelfan1
über den CommandButton CbÜbernehmen im UserForm wird der nachfolgende Code mit dem Match
lngZeile = Application.Match(cbWeg, Columns("B"), 0)
ausgeführt
Dim lngZeile As Long
Dim intSpalte As Integer
Dim OptButtons As MSForms.Control
Dim AuswahlPunkte As String
lngZeile = Application.Match(cbWeg, Columns("B"), 0)
'untersucht die Optionsschalter im Frame Punkte
For Each OptButtons In fraPunkte.Controls
If OptButtons.Value = True Then
AuswahlPunkte = OptButtons.Caption
End If
Next OptButtons
If TbFr.Value = True Then
If Cells(lngZeile, intSpalte + 6) > "" Then
Cells(lngZeile, intSpalte + 8).Value = cbMitglied.Value
Cells(lngZeile, intSpalte + 9).Value = AuswahlPunkte
cbMitglied = ""
cbWeg.Value = ""
End If
If Cells(lngZeile, intSpalte + 4) > "" And Cells(lngZeile, intSpalte + 5) > "" Then
Cells(lngZeile, intSpalte + 6).Value = cbMitglied.Value
Cells(lngZeile, intSpalte + 7).Value = AuswahlPunkte
cbMitglied = ""
cbWeg.Value = ""
End If
If Cells(lngZeile, intSpalte + 4) = "" And Cells(lngZeile, intSpalte + 6).Value = "" Then
Cells(lngZeile, intSpalte + 4).Value = cbMitglied.Value
Cells(lngZeile, intSpalte + 5).Value = AuswahlPunkte
cbMitglied = ""
cbWeg.Value = ""
optleer.Value = True
End If
Ich habe noch einen zweiten Match
lngZeile = Application.Match(cbMitglied, Columns("AM"), 0)
lngZeile = Application.Match(cbMitglied, Columns("AM"), 0)
If TbFr.Value = True And TbSonder1 = True And cbWeg = "" Then
If Cells(lngZeile, intSpalte + 49) > "" Then
Cells(lngZeile, intSpalte + 50) = txtSo1.Text
End If
If Cells(lngZeile, intSpalte + 48) > "" Then
Cells(lngZeile, intSpalte + 49) = txtSo1.Text
End If
If Cells(lngZeile, intSpalte + 48) = "" Then
Cells(lngZeile, intSpalte + 48) = txtSo1.Text
End If
cbMitglied = ""
TbFr.Value = False
TbSonder1 = False
End If
Allerdings erzeugt der zweite Match beim ausführen in Zeile
lngZeile = Application.Match(cbWeg, Columns("B"), 0)
den Laufzeitfehler "13" "Typen unverträglich"
Ich habe den zweiten Match mit
Dim lngZeile As Long, finden As Long
finden = Application.Match(cbMitglied, Columns("AM"), 0)
ausprobiert, es kommt aber an gleicher Stelle der gleiche Fehler
Ich habe jetzt einen zweiten CommandButton CbÜbernehmen2 angelegt und die beiden Matches getrennt.
Das funktioniert zwar, lieber wäre mir allerdings, wenn ich nur einen CommandButton hätte.
Kann man das mit
If Not Application.Match(cbWeg, Columns("B"), 0) is Nothing Then ....
oder beide Matches miteinander kombiniert
lösen?
Ich habe keine Ahnung wie dann der Code lauten müßte.
Ich hoffe auf eure Hilfe
https://www.herber.de/bbs/user/170907.xlsm
Gruß von Excelfan1
Anzeige