Visual Basic para Aplicaciones - Desplegable condicionado VBA, control de stock

Life is soft - evento anual de software empresarial
 
Vista:
sin imagen de perfil
Val: 1
Ha aumentado 1 puesto en Visual Basic para Aplicaciones (en relación al último mes)
Gráfica de Visual Basic para Aplicaciones

Desplegable condicionado VBA, control de stock

Publicado por Pol (1 intervención) el 22/03/2019 12:30:50
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.

fc3739f3cc6dd7776baf974318b137dd

Esto seria este codigo:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
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

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.

Muchas gracias por vuestro tiempo, si os hace falta mas informacion no tengo problema en proporcionarla
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder