Saltar al contenido

Crear una falsa barra de progreso


Recommended Posts

publicado

Hola a todos y todas;

Estoy intentado crear una falsa barra de progreso vinculada con el campo fecha e una tabla.

El objetivo es que una vez alcanzado el último día del año nos avise de la necesidad de crear una copia de seguridad.

Adjunto un modelo explicativo sobre el que estoy trabajando.

 

Saludos.

MProgreso.xlsm

publicado

Según entendí esto podría ser una posible solución.

Private Sub UserForm_Initialize()

Dim Contador As Integer, Maximo As Integer, Intervalo As Integer
Dim Inicio As Double
Dim X As Integer
Dim uf As Integer
Dim vValor As String
Dim vfano As Date

uf = Hoja10.Cells(Rows.Count, 1).End(xlUp).Row
vValor = Month(Hoja10.Cells(uf, 2))
vfano = "31/12/2021"
Me.btnCS.Visible = False
Select Case vValor

    Case 1
        Maximo = 25
    Case 2
        Maximo = 50
    Case 3
        Maximo = 75
    Case 4
        Maximo = 100
    Case 5
        Maximo = 125
    Case 6
        Maximo = 150
    Case 7
        Maximo = 175
    Case 8
        Maximo = 200
    Case 9
        Maximo = 225
    Case 10
        Maximo = 250
    Case 11
        Maximo = 275
    Case Else
        If CDate(Hoja10.Cells(uf, 2)) = CDate(vfano) Then
            Maximo = 300
            Me.btnCS.Visible = True
        End If
End Select

Me.Show
    For Contador = 1 To Maximo
            Inicio = Timer
                Do Until Timer - Inicio > Intervalo
                    X = DoEvents()
                Loop
                Me.lbl_Bar.Width = Contador
                Me.lbl_Porcentaje.Caption = "Cargando " & Format(Contador / Maximo, "Percent")
    Next Contador


End Sub

 

publicado

Algo más simplificado

Dim Contador As Integer, Maximo As Integer, Intervalo As Integer
Dim Inicio As Double
Dim X As Integer
Dim uf As Integer

uf = Hoja10.Cells(Rows.Count, 1).End(xlUp).Row
Maximo = Month(Hoja10.Cells(uf, 2)) * 25
Me.btnCS.Visible = False

Me.Show
    For Contador = 1 To Maximo
            Inicio = Timer
                Do Until Timer - Inicio > Intervalo
                    X = DoEvents()
                Loop
                Me.lbl_Bar.Width = Contador
                Me.lbl_Porcentaje.Caption = "Cargando " & Format(Contador / (Maximo), "Percent")
    Next Contador
If Maximo = 300 Then Me.btnCS.Visible = True


End Sub

 

publicado
Hace 6 minutos , JSDJSD dijo:

Algo más simplificado

Dim Contador As Integer, Maximo As Integer, Intervalo As Integer
Dim Inicio As Double
Dim X As Integer
Dim uf As Integer

uf = Hoja10.Cells(Rows.Count, 1).End(xlUp).Row
Maximo = Month(Hoja10.Cells(uf, 2)) * 25
Me.btnCS.Visible = False

Me.Show
    For Contador = 1 To Maximo
            Inicio = Timer
                Do Until Timer - Inicio > Intervalo
                    X = DoEvents()
                Loop
                Me.lbl_Bar.Width = Contador
                Me.lbl_Porcentaje.Caption = "Cargando " & Format(Contador / (Maximo), "Percent")
    Next Contador
If Maximo = 300 Then Me.btnCS.Visible = True


End Sub

 

Hola y muchas gracias por su respuesta JSDJSD.

Están casi bien las dos.

Hay un pequeño error.

En la primera macro al poner cualquier día del mes de diciembre se para, adjunto imagen:

image.thumb.png.1c6c2c3ab20d669acf738d64f58f6d08.png

En la segunda no pasa pero si pongo 30/12 no debería mostrar el botón "btnCS". En la imagen he puesto el día 20 pero inclusive con el día 1 ya pone al botón visible y este

solo debe aparecer el 31/12.

image.thumb.png.d40717346018e26e66ab1b004f4292cc.png

Si puedes ajustar un pelín más sería perfecto, en cualquier caso agradezco tú tiempo y esfuerzo.

Un saludo. 

publicado

Prueba ahora 

Private Sub UserForm_Initialize()

Dim Contador As Integer, Maximo As Integer, Intervalo As Integer
Dim Inicio As Double
Dim X As Integer
Dim uf As Integer

uf = Hoja10.Cells(Rows.Count, 1).End(xlUp).Row
Maximo = Month(Hoja10.Cells(uf, 2)) * 25
Me.btnCS.Visible = False

Me.Show
    For Contador = 1 To Maximo
            Inicio = Timer
                Do Until Timer - Inicio > Intervalo
                    X = DoEvents()
                Loop
                Me.lbl_Bar.Width = Contador
                Me.lbl_Porcentaje.Caption = "Cargando " & Format(Contador / (Maximo), "Percent")
    Next Contador
If Maximo = 300 And Hoja10.Cells(uf, 2) = "31/12/2021" Then Me.btnCS.Visible = True


End Sub

 

publicado
Hace 1 hora, JSDJSD dijo:

Prueba ahora 

Private Sub UserForm_Initialize()

Dim Contador As Integer, Maximo As Integer, Intervalo As Integer
Dim Inicio As Double
Dim X As Integer
Dim uf As Integer

uf = Hoja10.Cells(Rows.Count, 1).End(xlUp).Row
Maximo = Month(Hoja10.Cells(uf, 2)) * 25
Me.btnCS.Visible = False

Me.Show
    For Contador = 1 To Maximo
            Inicio = Timer
                Do Until Timer - Inicio > Intervalo
                    X = DoEvents()
                Loop
                Me.lbl_Bar.Width = Contador
                Me.lbl_Porcentaje.Caption = "Cargando " & Format(Contador / (Maximo), "Percent")
    Next Contador
If Maximo = 300 And Hoja10.Cells(uf, 2) = "31/12/2021" Then Me.btnCS.Visible = True


End Sub

 

Hola de nuevo JSDJSD,  disculpa la tardanza,  ahora si va bien. 

Muchísimas gracias y hasta la próxima. 

Saludos ? ? 

Archivado

Este tema está ahora archivado y está cerrado a más respuestas.

  • 109 ¿Te parecen útiles los tips de las funciones? (ver tema completo)

    1. 1. ¿Te parecen útiles los tips de las funciones?


      • No
      • Ni me he fijado en ellos

  • Current Donation Goals

    • Raised 0.00 EUR of 130.00 EUR target
  • Archivos

  • Estadísticas de descargas

    • Archivos
      188
    • Comentarios
      98
    • Revisiones
      29

    Más información sobre "Cambios en el Control Horario"
    Última descarga
    Por pegones1

    4    1

  • Crear macros Excel

  • Mensajes

    • Hola, veo que tienes 365, así que esta forma funcionará   Almacen.xlsx
    • Buenos días  @LeandroA espero estes bien Tengo un caso idéntico al planteado en la siguiente pregunta: Sin embargo, a diferencia de quien planteo originalmente la pregunta al correr el código no obtengo ningún resultado podrían ayudarme a resolver este inconveniente y que al hacer click en el Botón Guardar (CommandButton3) del Formulario RCS (frmrcs) el archivo pdf quede configurado con orientación vertical, márgenes superior, inferior, derecho e izquierdo = 1 y en página tamaño carta. Si acaso influye uso Microsoft Excel LTSC MSO (versión 2209 Compilación16.0.1.15629.20200) de 64 bits Mucho le sabre agradecer la ayuda que me pueda dar  RCS PRUEBA - copia.xlsm
    • @JSDJSDCon gusto mi estimado Para la opción 1: Sub Surtirhastadondealcanse() Dim ws As Worksheet Set ws = ThisWorkbook.Sheets(1) Dim filaInicio As Integer: filaInicio = 4 Dim filaFin As Integer: filaFin = 7 Dim colInventario As Integer: colInventario = 2 Dim colSolicitudesInicio As Integer: colSolicitudesInicio = 4 ' Columna C Dim colResultadoInicio As Integer: colResultadoInicio = 9 ' Columna I Dim colTotalSurtido As Integer: colTotalSurtido = 12 ' Columna L Dim colFinalInventario As Integer: colFinalInventario = 13 ' Columna M Dim numClientes As Integer: numClientes = 3 Dim fila As Integer, i As Integer For fila = filaInicio To filaFin Dim inventario As Double inventario = Val(ws.Cells(fila, colInventario).Value) Dim solicitudes(1 To 3) As Double Dim surtido(1 To 3) As Variant Dim totalSurtido As Double: totalSurtido = 0 ' Leer solicitudes For i = 1 To numClientes If IsNumeric(ws.Cells(fila, colSolicitudesInicio + i - 1).Value) Then solicitudes(i) = CDbl(ws.Cells(fila, colSolicitudesInicio + i - 1).Value) Else solicitudes(i) = 0 End If surtido(i) = "POR FALTA STOCK" Next i ' Surtir de acuerdo al inventario disponible For i = 1 To numClientes If solicitudes(i) > 0 Then If inventario >= solicitudes(i) Then surtido(i) = solicitudes(i) inventario = inventario - solicitudes(i) totalSurtido = totalSurtido + solicitudes(i) ElseIf inventario > 0 Then surtido(i) = inventario totalSurtido = totalSurtido + inventario inventario = 0 Else surtido(i) = "POR FALTA STOCK" End If End If Next i ' Escribir resultados en las columnas correspondientes para cada cliente For i = 1 To numClientes With ws.Cells(fila, colResultadoInicio + i - 1) If surtido(i) = "POR FALTA STOCK" Then .Value = surtido(i) .Font.Color = vbRed Else .Value = surtido(i) .Font.Color = vbBlack End If End With Next i ' Escribir total surtido y existencia final ws.Cells(fila, colTotalSurtido).Value = totalSurtido ws.Cells(fila, colFinalInventario).Value = inventario Next fila MsgBox "Resultado surtido cargado con éxito...", vbInformation End Sub Para la opción 2:   Sub surtirenpartesiguales() Dim ws As Worksheet Set ws = ThisWorkbook.Sheets(1) Dim filaInicio As Integer: filaInicio = 13 Dim filaFin As Integer: filaFin = 16 Dim colInventario As Integer: colInventario = 2 Dim colSolicitudesInicio As Integer: colSolicitudesInicio = 4 ' Columna C Dim colResultadoInicio As Integer: colResultadoInicio = 9 ' Columna I Dim colTotalSurtido As Integer: colTotalSurtido = 12 ' Columna L Dim colFinalInventario As Integer: colFinalInventario = 13 ' Columna M Dim numClientes As Integer: numClientes = 3 Dim fila As Integer, i As Integer For fila = filaInicio To filaFin Dim inventario As Double inventario = Val(ws.Cells(fila, colInventario).Value) Dim solicitudes(1 To 3) As Double Dim surtido(1 To 3) As Variant Dim totalSurtido As Double: totalSurtido = 0 Dim totalPedido As Double: totalPedido = 0 ' Leer solicitudes For i = 1 To numClientes If IsNumeric(ws.Cells(fila, colSolicitudesInicio + i - 1).Value) Then solicitudes(i) = CDbl(ws.Cells(fila, colSolicitudesInicio + i - 1).Value) totalPedido = totalPedido + solicitudes(i) Else solicitudes(i) = 0 End If surtido(i) = 0 Next i ' Si hay suficiente inventario, surtir lo que el cliente pide If inventario >= totalPedido Then For i = 1 To numClientes If solicitudes(i) > 0 And inventario >= solicitudes(i) Then surtido(i) = solicitudes(i) inventario = inventario - solicitudes(i) totalSurtido = totalSurtido + solicitudes(i) End If Next i Else ' Reparto base igualitario Dim baseSurtido As Long baseSurtido = Int(inventario / numClientes) For i = 1 To numClientes If solicitudes(i) > 0 Then If solicitudes(i) <= baseSurtido Then surtido(i) = solicitudes(i) inventario = inventario - solicitudes(i) totalSurtido = totalSurtido + solicitudes(i) Else surtido(i) = baseSurtido inventario = inventario - baseSurtido totalSurtido = totalSurtido + baseSurtido End If End If Next i ' Repartir sobrante restante uno por uno, respetando lo pedido Do While inventario > 0 For i = 1 To numClientes If surtido(i) < solicitudes(i) Then surtido(i) = surtido(i) + 1 totalSurtido = totalSurtido + 1 inventario = inventario - 1 If inventario = 0 Then Exit For End If Next i Loop End If ' Escribir resultados en las columnas correspondientes para cada cliente For i = 1 To numClientes With ws.Cells(fila, colResultadoInicio + i - 1) If surtido(i) = 0 Then .Value = "POR FALTA STOCK" .Font.Color = vbRed Else .Value = surtido(i) .Font.Color = vbBlack End If End With Next i ' Escribir total surtido y existencia final ws.Cells(fila, colTotalSurtido).Value = totalSurtido ws.Cells(fila, colFinalInventario).Value = inventario Next fila MsgBox "Resultado surtido cargado con éxito...", vbInformation End Sub Saludos, Diego
    • Buenos dias.  Estoy trabajando en una hoja para poder llevar un control de un pequeño almacén.  Tengo un pedido con varias líneas y "lotes" y necesito sacar las ubicaciones que coincidan con la referencia y lote que pone en el pedido. El problema viene cuando tengo la misma referencia y mismo lote en ubicaciones diferentes y necesito sacar la información en columnas diferentes. No se si  me he explicado bien, pero creo que con el ejemplo adjunto se entiende mejor. Agradecería mucho si me pudieran ayudar  Libro1.xlsx
    • Exelente solución mil gracias 
  • Visualizado recientemente

    • No hay usuarios registrado para ver esta página.
×
×
  • Crear nuevo...

Información importante

Echa un vistazo a nuestra política de cookies para ayudarte a tener una mejor experiencia de navegación. Puedes ajustar aquí la configuración. Pulsa el botón Aceptar, si estás de acuerdo.