Está en la página 1de 6

Private Sub ListBoxAgenda_DblClick(ByVal Cancel As MSForms.

ReturnBoolean)
Dim res As Integer
Dim seleccion As Integer

For a = 0 To ListBoxAgenda.ListCount
If ListBoxAgenda.Selected(a) = True Then
seleccion = a
Exit For
End If

Next a

If seleccion = Null Then


MsgBox " Debe seleccionar un cliente para poder visualizar", vbInformation, "
Mensaje "
Else

FACTURA.Show
FACTURA.LabelNumeroFactura.Caption = ListBoxAgenda.List(seleccion)
FACTURA.TextNombre.Value = ListBoxAgenda.Column(4, seleccion)
FACTURA.TextDocumento.Value = ListBoxAgenda.Column(5, seleccion)
FACTURA.TextCelular.Value = ListBoxAgenda.Column(6, seleccion)
FACTURA.TextEsferaRxFinalOD.Value = ListBoxAgenda.Column(7, seleccion)
FACTURA.TextADDRxFinalOD.Value = ListBoxAgenda.Column(8, seleccion)
FACTURA.TextEsferaRxFinalOI.Value = ListBoxAgenda.Column(9, seleccion)
FACTURA.TextADDRxFinalOI.Value = ListBoxAgenda.Column(10, seleccion)
FACTURA.TextBoxDPOD.Value = ListBoxAgenda.Column(11, seleccion)
FACTURA.ComboBoxTipodeLente.Value = ListBoxAgenda.Column(12, seleccion)
FACTURA.ComboBoxLente.Value = ListBoxAgenda.Column(13, seleccion)

End If

End Sub

' todo en mayuscula'


Private Sub TextBoxN�Factura_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
KeyAscii = Asc(UCase(Chr(KeyAscii)))
End Sub

Private Sub TextBoxN�Factura_Change()


NumeroDatos = Hoja2.Range("A" & Rows.Count).End(xlUp).Row
'MsgBox NumeroDatos
Hoja2.AutoFilterMode = False
Me.ListBoxAgenda = Clear
Me.ListBoxAgenda.RowSource = Clear
Me.TextDocumento = Clear
Me.TextNombre = Clear
y = 0
For Fila = 2 To NumeroDatos
Fact = Hoja2.Cells(Fila, 1).Value
If UCase(Fact) Like "*" & UCase(Me.TextBoxN�Factura.Value) & "*" Then
Me.ListBoxAgenda.AddItem
Me.ListBoxAgenda.List(y, 0) = Hoja2.Cells(Fila, 1).Value
Me.ListBoxAgenda.List(y, 1) = Hoja2.Cells(Fila, 2).Value
Me.ListBoxAgenda.List(y, 2) = Hoja2.Cells(Fila, 3).Value
Me.ListBoxAgenda.List(y, 3) = Hoja2.Cells(Fila, 4).Value
Me.ListBoxAgenda.List(y, 4) = Hoja2.Cells(Fila, 5).Value
Me.ListBoxAgenda.List(y, 5) = Hoja2.Cells(Fila, 6).Value
Me.ListBoxAgenda.List(y, 6) = Hoja2.Cells(Fila, 7).Value
Me.ListBoxAgenda.List(y, 7) = Hoja2.Cells(Fila, 8).Value
Me.ListBoxAgenda.List(y, 8) = Hoja2.Cells(Fila, 9).Value
Me.ListBoxAgenda.List(y, 9) = Hoja2.Cells(Fila, 10).Value

y = y + 1

End If
Next
End Sub

' todo en mayuscula'


Private Sub TextDocumento_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
KeyAscii = Asc(UCase(Chr(KeyAscii)))
End Sub

Private Sub TextDocumento_Change()


NumeroDatos = Hoja2.Range("A" & Rows.Count).End(xlUp).Row
'MsgBox NumeroDatos
Hoja2.AutoFilterMode = False
Me.ListBoxAgenda = Clear
Me.ListBoxAgenda.RowSource = Clear
Me.TextBoxN�Factura = Clear
Me.TextNombre = Clear
y = 0
For Fila = 2 To NumeroDatos
Codigo = Hoja2.Cells(Fila, 6).Value
If UCase(Codigo) Like "*" & UCase(Me.TextDocumento.Value) & "*" Then
Me.ListBoxAgenda.AddItem
Me.ListBoxAgenda.List(y, 0) = Hoja2.Cells(Fila, 1).Value
Me.ListBoxAgenda.List(y, 1) = Hoja2.Cells(Fila, 2).Value
Me.ListBoxAgenda.List(y, 2) = Hoja2.Cells(Fila, 3).Value
Me.ListBoxAgenda.List(y, 3) = Hoja2.Cells(Fila, 4).Value
Me.ListBoxAgenda.List(y, 4) = Hoja2.Cells(Fila, 5).Value
Me.ListBoxAgenda.List(y, 5) = Hoja2.Cells(Fila, 6).Value
Me.ListBoxAgenda.List(y, 6) = Hoja2.Cells(Fila, 7).Value
Me.ListBoxAgenda.List(y, 7) = Hoja2.Cells(Fila, 8).Value
Me.ListBoxAgenda.List(y, 8) = Hoja2.Cells(Fila, 9).Value
Me.ListBoxAgenda.List(y, 9) = Hoja2.Cells(Fila, 10).Value

y = y + 1

End If
Next
End Sub

' todo en mayuscula'


Private Sub TextNombre_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
KeyAscii = Asc(UCase(Chr(KeyAscii)))
End Sub

Private Sub TextNombre_Change()


NumeroDatos = Hoja2.Range("A" & Rows.Count).End(xlUp).Row
'MsgBox NumeroDatos
Hoja2.AutoFilterMode = False
Me.ListBoxAgenda = Clear
Me.ListBoxAgenda.RowSource = Clear
Me.TextBoxN�Factura = Clear
Me.TextDocumento = Clear
y = 0
For Fila = 2 To NumeroDatos
Nombre = Hoja2.Cells(Fila, 5).Value
If UCase(Nombre) Like "*" & UCase(Me.TextNombre.Value) & "*" Then
Me.ListBoxAgenda.AddItem
Me.ListBoxAgenda.List(y, 0) = Hoja2.Cells(Fila, 1).Value
Me.ListBoxAgenda.List(y, 1) = Hoja2.Cells(Fila, 2).Value
Me.ListBoxAgenda.List(y, 2) = Hoja2.Cells(Fila, 3).Value
Me.ListBoxAgenda.List(y, 3) = Hoja2.Cells(Fila, 4).Value
Me.ListBoxAgenda.List(y, 4) = Hoja2.Cells(Fila, 5).Value
Me.ListBoxAgenda.List(y, 5) = Hoja2.Cells(Fila, 6).Value
Me.ListBoxAgenda.List(y, 6) = Hoja2.Cells(Fila, 7).Value
Me.ListBoxAgenda.List(y, 7) = Hoja2.Cells(Fila, 8).Value
Me.ListBoxAgenda.List(y, 8) = Hoja2.Cells(Fila, 9).Value
Me.ListBoxAgenda.List(y, 9) = Hoja2.Cells(Fila, 10).Value

y = y + 1

End If
Next
End Sub

For i = 2 To uf
strg = b.Cells(i, 3).Value
If UCase(strg) Like UCase(TextBox1.Value) & �*� Then
a.Cells(fila, 1) = b.Cells(i, 1)
a.Cells(fila, 2) = b.Cells(i, 2)
a.Cells(fila, 3) = b.Cells(i, 3)
a.Cells(fila, 4) = b.Cells(i, 4)
a.Cells(fila, 5) = b.Cells(i, 5)
a.Cells(fila, 6) = b.Cells(i, 6)
a.Cells(fila, 7) = b.Cells(i, 7)
a.Cells(fila, 8) = b.Cells(i, 8)
a.Cells(fila, 9) = b.Cells(i, 9)
a.Cells(fila, 10) = b.Cells(i, 10)
a.Cells(fila, 11) = b.Cells(i, 11)
a.Cells(fila, 12) = b.Cells(i, 12)
fila = fila + 1
End If
Next i

'guarda en la segunda hoja'

Do While Hoja2.Cells(Fila1, 1) <> ""


Fila1 = Fila1 + 1
Loop

Hoja2.Cells(Fila1, 3) = TextFechaConsulta.Text

End Sub

Private Sub UserForm_Activate()


Me.ListBoxAgenda.RowSource = "AGENDA"
Me.ListBoxAgenda.ColumnCount = 10
End Sub
Dim w As Long

With ListBoxAgenda
.ColumnCount = 89
.List = Range("Historia").Value
.Clear
For w = 1 To [A99999].End(xlUp).Row
.AddItem
.List(.ListCount - 1, 0) = Cells(w, 1)
.List(.ListCount - 1, 1) = Cells(w, 2)
.List(.ListCount - 1, 2) = Cells(w, 3)
.List(.ListCount - 1, 3) = Cells(w, 4)
.List(.ListCount - 1, 4) = Cells(w, 5)
.List(.ListCount - 1, 5) = Cells(w, 6)
.List(.ListCount - 1, 6) = Cells(w, 7)
.List(.ListCount - 1, 7) = Cells(w, 8)
.List(.ListCount - 1, 8) = Cells(w, 9)
.List(.ListCount - 1, 9) = Cells(w, 10)
.List(.ListCount - 1, 10) = Cells(w, 11)
.List(.ListCount - 1, 12) = Cells(w, 12)
.List(.ListCount - 1, 13) = Cells(w, 13)
.List(.ListCount - 1, 14) = Cells(w, 14)
.List(.ListCount - 1, 15) = Cells(w, 15)
.List(.ListCount - 1, 16) = Cells(w, 16)
.List(.ListCount - 1, 17) = Cells(w, 17)
.List(.ListCount - 1, 18) = Cells(w, 18)
.List(.ListCount - 1, 19) = Cells(w, 19)
.List(.ListCount - 1, 20) = Cells(w, 20)
.List(.ListCount - 1, 21) = Cells(w, 21)
.List(.ListCount - 1, 22) = Cells(w, 22)
.List(.ListCount - 1, 23) = Cells(w, 23)
.List(.ListCount - 1, 24) = Cells(w, 24)
.List(.ListCount - 1, 25) = Cells(w, 25)
.List(.ListCount - 1, 26) = Cells(w, 26)
.List(.ListCount - 1, 27) = Cells(w, 27)
.List(.ListCount - 1, 28) = Cells(w, 28)
.List(.ListCount - 1, 29) = Cells(w, 29)
.List(.ListCount - 1, 30) = Cells(w, 30)
.List(.ListCount - 1, 31) = Cells(w, 31)
.List(.ListCount - 1, 32) = Cells(w, 32)
.List(.ListCount - 1, 33) = Cells(w, 33)
.List(.ListCount - 1, 34) = Cells(w, 34)
.List(.ListCount - 1, 35) = Cells(w, 35)
.List(.ListCount - 1, 36) = Cells(w, 36)
.List(.ListCount - 1, 37) = Cells(w, 37)
.List(.ListCount - 1, 38) = Cells(w, 38)
.List(.ListCount - 1, 39) = Cells(w, 39)
.List(.ListCount - 1, 40) = Cells(w, 40)
.List(.ListCount - 1, 41) = Cells(w, 41)
.List(.ListCount - 1, 42) = Cells(w, 42)
.List(.ListCount - 1, 43) = Cells(w, 43)
.List(.ListCount - 1, 44) = Cells(w, 44)
.List(.ListCount - 1, 45) = Cells(w, 45)
.List(.ListCount - 1, 46) = Cells(w, 46)
.List(.ListCount - 1, 47) = Cells(w, 47)
.List(.ListCount - 1, 48) = Cells(w, 48)
.List(.ListCount - 1, 49) = Cells(w, 49)
.List(.ListCount - 1, 50) = Cells(w, 50)
.List(.ListCount - 1, 51) = Cells(w, 51)
.List(.ListCount - 1, 52) = Cells(w, 52)
.List(.ListCount - 1, 53) = Cells(w, 53)
.List(.ListCount - 1, 54) = Cells(w, 54)
.List(.ListCount - 1, 55) = Cells(w, 55)
.List(.ListCount - 1, 56) = Cells(w, 56)
.List(.ListCount - 1, 57) = Cells(w, 57)
.List(.ListCount - 1, 58) = Cells(w, 58)
.List(.ListCount - 1, 59) = Cells(w, 59)
.List(.ListCount - 1, 60) = Cells(w, 60)
.List(.ListCount - 1, 61) = Cells(w, 61)
.List(.ListCount - 1, 62) = Cells(w, 62)
.List(.ListCount - 1, 63) = Cells(w, 63)
.List(.ListCount - 1, 64) = Cells(w, 64)
.List(.ListCount - 1, 65) = Cells(w, 65)
.List(.ListCount - 1, 66) = Cells(w, 66)
.List(.ListCount - 1, 67) = Cells(w, 67)
.List(.ListCount - 1, 68) = Cells(w, 68)
.List(.ListCount - 1, 69) = Cells(w, 69)
.List(.ListCount - 1, 70) = Cells(w, 70)
.List(.ListCount - 1, 71) = Cells(w, 71)
.List(.ListCount - 1, 72) = Cells(w, 72)
.List(.ListCount - 1, 73) = Cells(w, 73)
.List(.ListCount - 1, 74) = Cells(w, 74)
.List(.ListCount - 1, 75) = Cells(w, 75)
.List(.ListCount - 1, 76) = Cells(w, 76)
.List(.ListCount - 1, 77) = Cells(w, 77)
.List(.ListCount - 1, 78) = Cells(w, 78)
.List(.ListCount - 1, 79) = Cells(w, 79)
.List(.ListCount - 1, 80) = Cells(w, 80)
.List(.ListCount - 1, 81) = Cells(w, 81)
.List(.ListCount - 1, 82) = Cells(w, 82)
.List(.ListCount - 1, 83) = Cells(w, 83)
.List(.ListCount - 1, 84) = Cells(w, 84)
.List(.ListCount - 1, 85) = Cells(w, 85)
.List(.ListCount - 1, 86) = Cells(w, 86)

Next
End With

End Sub

On Error Resume Next


Set b = Sheets("Historia")
uf = b.Range("A" & Rows.Count).End(xlUp).Row
If Trim(TextNombre.Value) = Null Then
Me.ListBoxHistoria.RowSource = "Historia!A1:CH1" & uf
Exit Sub
End If
b.AutoFilterMode = False
Me.ListBoxHistoria = Clear
Me.ListBoxHistoria.RowSource = Clear
For i = 2 To uf
strg = b.Cells(i, 2).Value
If UCase(strg) Like UCase(TextNombre.Value) & " * " Then
Me.ListBoxHistoria.List(Me.ListBoxHistoria.ListCount - 1, 0) = b.Cells(i, 1)
Me.ListBoxHistoria.List(Me.ListBoxHistoria.ListCount - 1, 1) = b.Cells(i, 2)
End If
Next i
Me.ListBoxHistoria.ColumnWidths = "2cm;130 pt;60 pt;60 pt;20 pt;120 pt;60 pt;60
pt;60 pt;60 pt;60 pt;60 pt"
End Sub

'PASAR DATOS CON DOBLE CLICK'

Dim res As Integer


Dim seleccion As Integer

For a = 0 To ListBoxHistoria.ListIndex

If ListBoxHistoria.Selected(a) = True Then


seleccion = a
Exit For
End If

Next a

If seleccion = Null Then


MsgBox " Debe seleccionar un cliente para poder visualizar", vbInformation, "
Mensaje "
Else

También podría gustarte