¿Traer datos de una hoja de cálculo a un formulario de excel visual basic?
Estoy creando un sistema de inventario y tengo un problema con los formularios de salida y entrada de producto.
Tengo la lista de producto con su código nombre marca y otros
Quiero que al introducir el código salga el nombre del producto la marca las unidades disponibles ó que si selecciono el nombre del producto me arroje el código la marca y la disponibilidad.
Los datos están en la siguiente foto.
He buscado mucho pero no he encontrado. Vi un video que fue el más parecido pero no me funcionó. Este es el link
https://youtu.be/t39GJ_XmX8I ya me dijeron que la función vlookup no me sirve
Esta es la imágenen del formulario

y esta de la lista de excel

Subo el código del formulario porque me habían tratado de ayudar pero no me funcionó
Private Sub codigo_Change()
End Sub
'0--48
'9--57
Private Sub codigo_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
If Not (KeyAscii >= 48 And KeyAscii <= 57) Then
KeyAscii = 0
End If
End Sub
Private Sub guardar_Click()
Sheets("RSD").Select
NR = Application.WorksheetFunction.CountA(Range("E:E"))
If producto.Text = "" Then
MsgBox ("Introduzca El Nombre Del Producto O Artículo")
ElseIf motivo.Text = "" Then
MsgBox ("Introduzca El Motivo De Salida Del Producto")
ElseIf unidades.Value = "" Then
MsgBox ("Introduzca Las Unidades Que Salen Del Inventario")
ElseIf precio.Value = "" Then
precio = "Sin Precio"
ElseIf MsgBox("¿Desea Guardar?", vbYesNo, "Confirmar") = vbNo Then Exit Sub
codigo = ""
producto = ""
marca = ""
disponible = ""
motivo = ""
unidades = ""
precio = ""
codigo.SetFocus
Else
Cells(NR + 1, 3) = Val(codigo)
Cells(NR + 1, 5) = producto
Cells(NR + 1, 4) = marca.Caption
Cells(NR + 1, 6) = Val(disponible)
Cells(NR + 1, 7) = motivo
Cells(NR + 1, 8) = Val(unidades)
Cells(NR + 1, 9) = Val(precio)
codigo = ""
producto = ""
marca = ""
disponible = ""
motivo = ""
unidades = ""
precio = ""
codigo.SetFocus
End If
End Sub
Private Sub marca_Click()
End Sub
Private Sub producto_Change()
End Sub
'a--97
'z--122
'A--65
'Z--90
' --32
'ñ--164
Private Sub producto_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
If Not (KeyAscii >= 97 And KeyAscii <= 122 Or KeyAscii >= 65 And KeyAscii <= 90 Or KeyAscii = 32 Or KeyAscii >= 164) Then
KeyAscii = 0
End If
End Sub
Private Sub motivo_Change()
End Sub
'a--97
'z--122
'A--65
'Z--90
' --32
'ñ--164
Private Sub motivo_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
If Not (KeyAscii >= 97 And KeyAscii <= 122 Or KeyAscii >= 65 And KeyAscii <= 90 Or KeyAscii = 32 Or KeyAscii >= 164) Then
KeyAscii = 0
End If
End Sub
Private Sub unidades_Change()
End Sub
'0--48
'9--57
Private Sub unidades_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
If Not (KeyAscii >= 48 And KeyAscii <= 57) Then
KeyAscii = 0
End If
End Sub
Private Sub precio_Change()
End Sub
'0--48
'9--57
Private Sub precio_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
If Not (KeyAscii >= 48 And KeyAscii <= 57) Then
KeyAscii = 0
End If
End Sub
Private Sub limpiar_Click()
codigo = ""
producto = ""
marca = ""
disponible = ""
motivo = ""
unidades = ""
precio = ""
codigo.SetFocus
End Sub
Private Sub salir_Click()
Unload Me
End Sub
Private Sub UserForm_Activate()
codigo.SetFocus
With motivo
.RowSource = "MotivoRSD"
.ListIndex = 0
End With
With producto
.RowSource = "Productotabla"
.ListIndex = 0
End With
End Sub
4 respuestas
Respuesta de James Bond
2
Respuesta de Ahrens Ruano
1
Respuesta de Elsa Matilde
1
Respuesta de Programar Excel
1

