Control stock en excel VBA

1 post / 0 nuevos
polbq
Imagen de polbq
Offline
última acción: Hace 4 años 11 meses
alta: 22/03/2019 - 12:26
Puntos: 50
Control stock en excel VBA

Hola buenos dias, mi nombre es Pol y estoy realizando un excel mediante VBA para realizar un control de stock.
Actualmente estoy atascado. 

El excel esta estrocutrado de la siguinte forma: Columna A (familia grande), Columna B (familia pequeña), Columna C (producto). Estos 3 desplegables estan condicionados. Los datos los selecciona del una hoja llamada "full2" situada en el mismo excel.

El problema es que una vez encuentre el producto en concreto automaticamente se ponga en el texbox llamado preveedor.value (columna D) y en preciounitario.value (columna E) salga el precio del articulo seleccionado. 

Llevo dias peleandome con este tema y seguro que es una tonteria, agradeceria ayuda.

Adjunto el codigo que tengo por el momento 

Private Sub UserForm_Activate()
    Set h2 = Sheets("full2")
    For i = 2 To h2.Range("A" & Rows.Count).End(xlUp).Row
        Call agregar(generic, h2.Cells(i, "A"))
    Next
End Sub
Sub agregar(combo As ComboBox, dato As String)
 
    For i = 0 To combo.ListCount - 1
        Select Case StrComp(combo.List(i), dato, vbTextCompare)
            Case 0: Exit Sub
            Case 1: combo.AddItem dato, i: Exit Sub
        End Select
 
    Next
    combo.AddItem dato
End Sub
Private Sub generic_Change()
    especific.Clear
    especific2.Clear
    Set h2 = Sheets("full2")
    For i = 2 To h2.Range("A" & Rows.Count).End(xlUp).Row
        If h2.Cells(i, "A").Value = generic.Value Then
            Call agregar(especific, h2.Cells(i, "B"))
        End If
    Next
End Sub
Private Sub especific_Change()
    especific2.Clear
    Set h2 = Sheets("full2")
    For i = 2 To h2.Range("A" & Rows.Count).End(xlUp).Row
        If h2.Cells(i, "A").Value = generic.Value And _
           h2.Cells(i, "B").Value = especific.Value Then
            Call agregar(especific2, h2.Cells(i, "C"))
        End If
    Next
End Sub
 
Private Sub especific2_Change()
 
Set h2 = Sheets("full2")
    For i = 2 To h2.Range("A" & Rows.Count).End(xlUp).Row
        If h2.Cells(i, "A").Value = generic.Value And _
           h2.Cells(i, "B").Value = especific.Value And _
           h2.Cells(i, "C").Value = especific2.Value Then
 
             Next
 
    End If
End Sub

 

 

AdjuntoTamaño
Image icon captura.png140.31 KB

Etiquetas: