Mostrar cuanto falta para la próxima mantención

Dante Amor

Hola Dan, disculpa tantas preguntas, pero resulta que el código que me ayudaste funciona hasta los 4999 de ahí en adelante no funciona la formula matemática..

Ejemplo si tengo 4000 en la columna siguiente me muestra 1000 eso esta bien pero si tengo 5000 me muestra 0 en la columna siguiente y de ahí en adelante no funciona .

Sin embargo si tengo dos filas con el mismo código que este estaría en la columna A ahí funciona perfecto el código . Le adjunto imágenes y el código

Gracias Dan

Private Sub txtbuscar_Change()
    Lb_buscar.Clear
Lb_buscar.ColumnCount = 6
    Lb_buscar.ColumnWidths = "60;100;90;110;120"
    For i = 2 To Hoja3.Range("A" & Rows.Count).End(xlUp).Row
        cadena = UCase(Hoja3.Cells(i, 1))
        If cadena Like "*" & UCase(txtbuscar) & "*" And Hoja3.Cells(i, "A") <> 0 Then
            existe = False
            '
            For j = 0 To Lb_buscar.ListCount - 1
                If Hoja3.Cells(i, "A").Text = Lb_buscar.List(j) Then
                    Lb_buscar.List(j, 1) = Lb_buscar.List(j, 1) + Hoja3.Cells(i, "P").Value
                    prox = 5000 - (Lb_buscar.List(j, 1) - Int(Lb_buscar.List(j, 1) / 5000) * 5000)
                    Lb_buscar.List(j, 2) = prox
                    Lb_buscar.List(j, 3) = Hoja3.Cells(i, "R").Value
                    existe = True
                    Exit For
                End If
            Next
            If existe = False Then
                Lb_buscar.AddItem Hoja3.Cells(i, "A").Value
                Lb_buscar.List(Lb_buscar.ListCount - 1, 1) = Hoja3.Cells(i, "P").Value
                Lb_buscar.List(Lb_buscar.ListCount - 1, 2) = 5000 - Hoja3.Cells(i, "P").Value
                Lb_buscar.List(Lb_buscar.ListCount - 1, 3) = Format(Hoja3.Cells(i, "R").Value, "short date")
            End If
        End If
    Next
End Sub

1 respuesta

Respuesta
1

Dante Amor

Hola Dan

Resolví el problema me costo pero probando y probando lo solucione..

Agregue estas líneas y funciono.. solo me faltan 2 cosas que solucionar para mi proyecto

Gracias saludos

If Lb_buscar.List(j, 1) < 5000 Then
                 Lb_buscar.List(Lb_buscar.ListCount - 1, 2) = 5000 - Hoja3.Cells(i, "P").Value
                Else
Private Sub txtbuscar_Change()
Application.ScreenUpdating = False
    Lb_buscar.Clear
Lb_buscar.ColumnCount = 6
    Lb_buscar.ColumnWidths = "60;100;90;110;120"
    For i = 2 To Hoja3.Range("A" & Rows.Count).End(xlUp).Row
        cadena = UCase(Hoja3.Cells(i, 1))
        If cadena Like "*" & UCase(txtbuscar) & "*" And Hoja3.Cells(i, "A") <> 0 Then
            existe = False
            '
            For j = 0 To Lb_buscar.ListCount - 1
                If Hoja3.Cells(i, "A").Text = Lb_buscar.List(j) Then
                    Lb_buscar.List(j, 1) = Lb_buscar.List(j, 1) + Hoja3.Cells(i, "P").Value
                    prox = 5000 - (Lb_buscar.List(j, 1) - Int(Lb_buscar.List(j, 1) / 5000) * 5000)
                    Lb_buscar.List(j, 2) = prox
                    Lb_buscar.List(j, 3) = Hoja3.Cells(i, "R").Value
                    existe = True
                    Exit For
                End If
            Next
            If existe = False Then
                Lb_buscar.AddItem Hoja3.Cells(i, "A").Value
                Lb_buscar.List(Lb_buscar.ListCount - 1, 1) = Hoja3.Cells(i, "P").Value
                If Lb_buscar.List(j, 1) < 5000 Then
                 Lb_buscar.List(Lb_buscar.ListCount - 1, 2) = 5000 - Hoja3.Cells(i, "P").Value
                Else
                Lb_buscar.List(Lb_buscar.ListCount - 1, 2) = 10000 - Hoja3.Cells(i, "P").Value
                Lb_buscar.List(Lb_buscar.ListCount - 1, 3) = Format(Hoja3.Cells(i, "R").Value, "short date")
            End If
            End If
        End If
    Next
End Sub

Añade tu respuesta

Haz clic para o

Más respuestas relacionadas