Hallar valor en ListBox, eliminarlo de ListBox y copiarlo en Hoja de Excel

Necesito escanear un valor (Cód. SAP) en el TextBox3, Hallar el Cód. SAP en el ListBox1, al hallarlo, eliminar la fila del ListBox1 y copiarlo en la Hoja2 a partir del ultima fila con datos. Así sucesivamente hasta hallar todos los códigos, al acabar que salga un mensaje "Pedido completado" y al aceptar que se situé en el TextBox1. Si hay algún código que no corresponde que salga un mensaje "Código no solicitado". Adjunto código.

Dim i As Integer
Private Sub CommandButton1_Click()
If Me.TextBox1.Value = "" Then Exit Sub
Me.ListBox1.Clear
J = 1
Filas = Range("a1").CurrentRegion.Rows.Count
For i = 2 To Filas
    If LCase(Cells(i, J).Offset(0, 0).Value) Like "*" & LCase(Me.TextBox1.Value) & "*" Then
        Me.ListBox1.AddItem Cells(i, J)
        Me.ListBox1.List(Me.ListBox1.ListCount - 1, 1) = Cells(i, J).Offset(0, 1)
        Me.ListBox1.List(Me.ListBox1.ListCount - 1, 2) = Cells(i, J).Offset(0, 2)
        Me.ListBox1.List(Me.ListBox1.ListCount - 1, 3) = Cells(i, J).Offset(0, 3)
    Else
    End If
Next i
For x = 0 To ListBox1.ListCount - 1
If ListBox1.List(x, 0) <> "" Then
m = m + 1
End If
Next
If m = 0 Then
MsgBox "NO SE ENCONTRÓ EL PEDIDO", vbExclamation
Else
TextBox2.Value = m
End If
TextBox2.Value = m
Exit Sub
End Sub
Private Sub UserForm_Activate()
With ListBox1
    .ColumnCount = 3
    .ColumnWidths = "60 pt;40 pt;60 pt"
End With
End Sub

Añade tu respuesta

Haz clic para o