Está en la página 1de 12

Public DON As String

Public DON2 As String

Sub BUSCARARTICULOS()

Buscar_Articulos.Show

End Sub

Private Sub LISTA_ARTICULOS_DblClick(ByVal Cancel As MSForms.ReturnBoolean) 'Colocar el


Name del cuadro de lista

Application.ScreenUpdating = False

On Error GoTo ERR1:

L = LISTA_ARTICULOS.List(LISTA_ARTICULOS.ListIndex, 0) 'Colocar el Name del cuadro de lista dos


veces

Sheets("ARTICULOS").Select 'Hoja donde se van a extraer los articulos

Range("B5").Select 'Celda donde empieza el rango de los articulos que se van a extraer

While ActiveCell.Value <> "" And ActiveCell.Value <> Val(L) And ActiveCell.Value <> L
ActiveCell.Offset(1, 0).Select

Wend

If ActiveCell.Value = "" Then

Else

ActiveCell.Offset(0, 0).Select 'el segundo cero es la culumna donde extraeremos la información.

NOMB1 = ActiveCell.Value

If DON = "FACTURA" Then 'el texto entre comillas debe ser igual al de la hoja que se pegara la
información y tambien debe colocarce talcual en la celda A1 de la hoja que se abrira el userform

Sheets("FACTURA").Select 'Hoja donde se pegará la información

Range("B14").Select 'Celda donde se pegará la información

While ActiveCell.Value <> ""

ActiveCell.Offset(1, 0).Select 'dejar igual

Wend

ActiveCell.Value = NOMB1

End If

End If

If VARIOS = False Then 'Este es el Name que tiene la casilla de verificación

Unload Me

End If

ERR1:

Application.ScreenUpdating = True

End Sub

Private Sub CODIGO_ARTICULOS_Change() 'Colocar el Name del cuadro de texto


Application.ScreenUpdating = False

Sheets("ARTICULOS").Select 'Hoja de la lista de articulos

Range("B5").Select 'Primera celda del rango de la base de los articulos

LISTA_ARTICULOS.Clear 'Colocar el Name del cuadro de lista

While ActiveCell.Value <> ""

M = InStr(1, UCase(ActiveCell.Value), UCase(CODIGO_ARTICULOS.Text)) 'Colocar el Name del


cuadro de texto en cuestión

If M > 0 Then

'Remplazar LISTA_ARTICULOS por el Name del cuadro de lista que usted tiene

LISTA_ARTICULOS.ColumnCount = 3 'Colocar la cantidad de columna que tendrá el cuadro de lista

LISTA_ARTICULOS.AddItem

LISTA_ARTICULOS.List(LISTA_ARTICULOS.ListCount - 1, 0) = ActiveCell.Value 'Repetir esta y la


siguiente linea para cada columna que se desee tener.

ActiveCell.Offset(0, 1).Select

LISTA_ARTICULOS.List(LISTA_ARTICULOS.ListCount - 1, 1) = ActiveCell.Value

ActiveCell.Offset(0, 1).Select

LISTA_ARTICULOS.List(LISTA_ARTICULOS.ListCount - 1, 2) = ActiveCell.Value

ActiveCell.Offset(0, -2).Select 'Colocar la ultima columna en negativo

End If

ActiveCell.Offset(1, 0).Select

Wend

Sheets(DON).Select

Range("A1").Select

Application.ScreenUpdating = True

End Sub

Private Sub DESCRIPCION_ARTICULOS_Change() 'Colocar el Name del cuadro de texto


Application.ScreenUpdating = False

Sheets("ARTICULOS").Select 'Hoja de donde se extraerá los articulos

Range("C5").Select 'Celda del rango de donde se extraerá los articulos

LISTA_ARTICULOS.Clear 'Colocar el Name del cuadro de lista

While ActiveCell.Value <> ""

M = InStr(1, UCase(ActiveCell.Value), UCase(DESCRIPCION_ARTICULOS.Text)) 'Colocar el Name del


cuadro de texto en cuestión

If M > 0 Then

'Remplazar LISTA_ARTICULOS por el Name del cuadro de lista

LISTA_ARTICULOS.ColumnCount = 3 'Colocar la cantidad de columna que tendrá el cuadro de lista

LISTA_ARTICULOS.AddItem

ActiveCell.Offset(0, -1).Select 'Colocar el numero de columna en negativo donde esta el valor que
se desea para este cuadro de texto

LISTA_ARTICULOS.List(LISTA_ARTICULOS.ListCount - 1, 0) = ActiveCell.Value 'Repetir esta y la


siguiente linea para cada columna que se desee tener.

ActiveCell.Offset(0, 1).Select

LISTA_ARTICULOS.List(LISTA_ARTICULOS.ListCount - 1, 1) = ActiveCell.Value

ActiveCell.Offset(0, 1).Select

LISTA_ARTICULOS.List(LISTA_ARTICULOS.ListCount - 1, 2) = ActiveCell.Value

ActiveCell.Offset(0, -1).Select 'Colocar la diferencia en negativo del numero de columna que hay
menos el numero de columna usada para el cuadro de texto

End If

ActiveCell.Offset(1, 0).Select

Wend

Sheets(DON).Select

Range("A1").Select

Application.ScreenUpdating = True
End Sub

Private Sub UserForm_Activate()

Application.ScreenUpdating = False

Range("A1").Select

DON = ActiveCell.Value

Sheets("ARTICULOS").Select 'Colocar hoja de donde se van a extraer los articulos

Range("B5").Select 'Colocar la celda de donde empieza el rango de los articulos

While ActiveCell.Value <> ""

ActiveCell.Offset(0, 10).Select 'Dejar igual

If DON2 <> "MODART" Then

If ActiveCell.Value = 0 Then

ActiveCell.Offset(0, -10).Select

'Remplazar LISTA_ARTICULOS por el Name del cuadro de lista

LISTA_ARTICULOS.ColumnCount = 3 'Colocar la cantidad de columna que tendrá el cuadro de


lista

LISTA_ARTICULOS.AddItem

LISTA_ARTICULOS.List(LISTA_ARTICULOS.ListCount - 1, 0) = ActiveCell.Value

ActiveCell.Offset(0, 1).Select

LISTA_ARTICULOS.List(LISTA_ARTICULOS.ListCount - 1, 1) = ActiveCell.Value

ActiveCell.Offset(0, 1).Select

LISTA_ARTICULOS.List(LISTA_ARTICULOS.ListCount - 1, 2) = ActiveCell.Value

ActiveCell.Offset(1, -2).Select 'Colocar la ultima columna en negativo

Else
ActiveCell.Offset(1, -10).Select

End If

Else

'Remplazar LISTA_ARTICULOS por el Name del cuadro de lista

ActiveCell.Offset(0, -10).Select

LISTA_ARTICULOS.ColumnCount = 3 'Colocar la cantidad de columna que tendrá el cuadro de


lista

LISTA_ARTICULOS.AddItem

LISTA_ARTICULOS.List(LISTA_ARTICULOS.ListCount - 1, 0) = ActiveCell.Value

ActiveCell.Offset(0, 1).Select

LISTA_ARTICULOS.List(LISTA_ARTICULOS.ListCount - 1, 1) = ActiveCell.Value

ActiveCell.Offset(0, 1).Select

LISTA_ARTICULOS.List(LISTA_ARTICULOS.ListCount - 1, 2) = ActiveCell.Value

ActiveCell.Offset(1, -2).Select 'Colocar la ultima columna en negativo

End If

Wend

Sheets(DON).Select

Range("A1").Select

Application.ScreenUpdating = True

End Sub
TEXTO= PRONOMBRE

LISTBOX= LISTA
FOMULARIOGUIA

49,95 pt;90 pt;49,95 pt;49,95 pt;49,95 pt;49,95 pt;49,95 pt

PARA LLAMAR A MI FORMULARIO ESTE CODIGO LO VAMOS A PEGAR EN UN MODULO

Sub buscarproductos_1()

FOMULARIOFA.Show

End Sub

Private Sub PRONOMBRE_Change()

Application.ScreenUpdating = False

Sheets("Productos").Select

Range("C9").Select

LISTA.Clear

While ActiveCell.Value <> ""

M = InStr(1, UCase(ActiveCell.Value), UCase(PRONOMBRE.Text))

If M > 0 Then

LISTA.ColumnCount = 7

LISTA.AddItem

ActiveCell.Offset(0, -1).Select

LISTA.List(LISTA.ListCount - 1, 0) = ActiveCell.Value
ActiveCell.Offset(0, 1).Select

LISTA.List(LISTA.ListCount - 1, 1) = ActiveCell.Value

ActiveCell.Offset(0, 1).Select

LISTA.List(LISTA.ListCount - 1, 2) = ActiveCell.Value

ActiveCell.Offset(0, 1).Select

LISTA.List(LISTA.ListCount - 1, 3) = ActiveCell.Value

ActiveCell.Offset(0, 1).Select

LISTA.List(LISTA.ListCount - 1, 4) = ActiveCell.Value

ActiveCell.Offset(0, 1).Select

LISTA.List(LISTA.ListCount - 1, 5) = ActiveCell.Value

ActiveCell.Offset(0, 1).Select

LISTA.List(LISTA.ListCount - 1, 6) = ActiveCell.Value

ActiveCell.Offset(0, -5).Select

End If

ActiveCell.Offset(1, 0).Select

Wend

Sheets("Facturacion").Select

Range("A1").Select

Application.ScreenUpdating = True

End Sub
Private Sub UserForm_Activate()

Application.ScreenUpdating = False

Sheets("Productos").Select

Range("B9").Select

While ActiveCell.Value <> ""

ActiveCell.Offset(0, 50).Select

If ActiveCell.Value = 0 Then

ActiveCell.Offset(0, -50).Select

LISTA.ColumnCount = 7

LISTA.AddItem

LISTA.List(LISTA.ListCount - 1, 0) = ActiveCell.Value

ActiveCell.Offset(0, 1).Select

LISTA.List(LISTA.ListCount - 1, 1) = ActiveCell.Value

ActiveCell.Offset(0, 1).Select

LISTA.List(LISTA.ListCount - 1, 2) = ActiveCell.Value

ActiveCell.Offset(0, 1).Select

LISTA.List(LISTA.ListCount - 1, 3) = ActiveCell.Value

ActiveCell.Offset(0, 1).Select

LISTA.List(LISTA.ListCount - 1, 4) = ActiveCell.Value

ActiveCell.Offset(0, 1).Select

LISTA.List(LISTA.ListCount - 1, 5) = ActiveCell.Value

ActiveCell.Offset(0, 1).Select

LISTA.List(LISTA.ListCount - 1, 6) = ActiveCell.Value
ActiveCell.Offset(1, -6).Select

Else

ActiveCell.Offset(1, -50).Select

End If

Wend

Sheets("Facturacion").Select

Range("A1").Select

Application.ScreenUpdating = True

End Sub

Private Sub LISTA_DblClick(ByVal Cancel As MSForms.ReturnBoolean)

Application.ScreenUpdating = False

On Error GoTo ERR:

L = LISTA.List(LISTA.ListIndex, 0)

Sheets("Productos").Select

Range("B9").Select

While ActiveCell.Value <> "" And ActiveCell.Value <> L And ActiveCell.Value <> Val(L)

ActiveCell.Offset(1, 0).Select

Wend

If ActiveCell.Value = "" Then

Unload Me

FORMULARIO.Show

Else

mensaje = LISTA.List(LISTA.ListIndex, 6)
If mensaje > 0 Then

COD1 = ActiveCell.Value

ActiveCell.Offset(0, 0).Select

NOMB1 = ActiveCell.Value

Sheets("Facturacion").Select

Rows("10:10").Select

Selection.Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove

Rows("10:10").Interior.Color = RGB(255, 255, 255)

Rows("10:10").Font.ColorIndex = RGB(0, 0, 0)

Range("E10").Select

Selection.NumberFormat = "$ #,##0.00"

Range("F10").Select

Selection.NumberFormat = "$ #,##0.00"

Range("B10").Select

ActiveCell.Value = NOMB1

Unload Me

Else

MsgBox "No puedes seleccionar un producto con stock : " & mensaje

End If

End If
ERR:

End Sub

También podría gustarte