Im unteren Code kann ich in Textbox27 eine 5 stellige Zahl eingeben,der mir dann im Worksheets("Artikeln") in Spalte A den übereinstimmenden Wert sucht.
Nun möchte ich aber das mir der Wert von Spalte B in Textbox29 anzeigt.
Z.B. Gebe in Textbox27 12345 ein, und diese Zahl befindet sich in ("Artikeln") in A50 nun sollte mir der Text von B50 in Textbox29 angezeigt werden.
Könnte mir bitte dazu jemand weiterhelfen ?
Gruß
Heinz
Option Explicit
Dim UF As New CUserForm
Dim Gelesen As Boolean
Private Sub CommandButton1_Click()
Application.ScreenUpdating = False
Sheets("Artikeln").Unprotect Password:="hh"
Dim A As Long, myRow
If TextBox27 = "" Then
MsgBox "Es wurde keine SAP Nummer eingegeben." ', vbCritical
TextBox27.SetFocus
TextBox27.Text = ""
MsgBox "Es wurde nichts übernommen." ', vbCritical
Exit Sub
Else
With Worksheets("Artikeln") 'Anpassen
myRow = Application.Match(CSng(TextBox27), .Columns(1), 0)
If IsNumeric(myRow) Then
For A = 1 To 26
If IsNumeric(Me("ComboBox" & A)) Then
.Cells(myRow, A + 26) = CDbl(Me("ComboBox" & A).Value)
Else
.Cells(myRow, A + 26) = Me("ComboBox" & A).Value
End If
Next A
Else
MsgBox "SAP-Nr. " & TextBox27 & vbLf & "ist nicht vorhanden", vbCritical
MsgBox "Es wurde nichts übernommen." ', vbCritical
TextBox27.SetFocus
TextBox27.Text = ""
Exit Sub
End If
End With
End If
Sheets("Artikeln").Protect Password:="hh"
MsgBox "Werte wurden eingetragen!"
'Unload Pruefung
For A = 1 To 26
Me("ComboBox" & A).Value = ""
Next A
TextBox27.SetFocus
TextBox27.Text = ""
Application.ScreenUpdating = True
End Sub
Private Sub TextBox27_KeyUp(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
Application.ScreenUpdating = False
Dim A As Long, myRow
' For A = 1 To 26
' Me("TextBox" & A) = ""
' Next A
If TextBox27 "" Then
If IsNumeric(TextBox27) Then
With Worksheets("Artikeln")
myRow = Application.Match(CSng(TextBox27), .Columns(1), 0)
If Len(TextBox27) = 5 And IsNumeric(myRow) Then
For A = 1 To 26
Me("ComboBox" & A).Value = .Cells(myRow, A + 26)
Next A
Gelesen = True
ElseIf Gelesen Then
For A = 1 To 26
Me("ComboBox" & A).Value = ""
Next A
Gelesen = False
End If
End With
Else
MsgBox "Text ist nicht zugelassen"
TextBox27 = ""
End If
'ElseIf Me.TextBox27 "" Then
'MsgBox "Text ist nicht zugelassen"
'TextBox27 = ""
'End If
End If
Application.ScreenUpdating = True
End Sub
Private Sub UserForm_Initialize()
Application.ScreenUpdating = False
Dim A As Long
With Sheets("Vorlage")
For A = 1 To 26
If .Cells(2, A) "" Then
Me("ComboBox" & A).RowSource = "Vorlage!" & _
.Range(.Cells(2, A), .Cells(.Rows.Count, A).End(xlUp)).Address(0, 0)
End If
Next A
End With
With UF
.MaxButton = True
.MinButton = True
.BorderStyle = xlFest
.Create Me
End With
Application.ScreenUpdating = True
End Sub