juannavarro

juannavarro

Ya tengo la solución la pongo por si alguien lo necesita Private Sub CommandButton1_Click() 'Boton efectuar consulta Application
 España @juannavarro desde - visto
Preguntar

Experiencia

Ya tengo la solución la pongo por si alguien lo necesita
Private Sub CommandButton1_Click()
'Boton efectuar consulta
Application.ScreenUpdating = False
'Depuramos datos
Cliente = ComboBox1
Desde = TextBox1
Hasta = TextBox2
If Cliente = "" Then Cliente = "*"
If Desde = "" Then Desde = "01/01/1980"
If Hasta = "" Then Hasta = Date
Desde = CDate(Desde)
Hasta = CDate(Hasta)
'Limpiamos y dimensionamos listas
ListBox1.Clear: ListBox1.ColumnWidths = "18;30;50;100;100"
ListBox2.Clear: ListBox2.ColumnWidths = "20;20;20;20;20;20;20;20;20;20"
ListBox3.Clear: ListBox3.ColumnWidths = "20;20;20;20;20;20;20;20;40;80"
'Se activa la hoja hoja1
Sheets("Alimentos").Activate
Seleccionado = False
'Seleccionamos ventas
For x = 6 To Cells.Find("*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
FECHA = CDate(Cells(x, 3))
If Cells(x, 6) Like Cliente And _
(Not FECHA < Desde And Not FECHA > Hasta) Then
Cells(x, 6).Select
Seleccionado = True
ListBox1.AddItem "": ListBox2.AddItem "": ListBox3.AddItem ""
For y = 1 To 3: ListBox1.List(ListBox1.ListCount - 1, y - 1) = Cells(x, y): Next y
For y = 6 To 7: ListBox1.List(ListBox1.ListCount - 1, y - 3) = Cells(x, y): Next y
For y = 10 To 19: ListBox2.List(ListBox2.ListCount - 1, y - 10) = Cells(x, y): Next y
For y = 20 To 29: ListBox3.List(ListBox3.ListCount - 1, y - 20) = Cells(x, y): Next y
End If
Next x
End Sub.

Aún no ha realizado ninguna actividad pública.