Saltar al contenido
View in the app

A better way to browse. Learn more.

Ayuda Excel

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Detener un bucle infinito Do While a demanda

publicado

Hola, Buenas tardes

Alguien tiene idea de como puede detener un bucle infinito Do while con otra macro en VBA excel. Necesito generar 2 CTA a la macro, una para iniciar y otra para poder pararla, pero mientras el bucle se este ejecutado no es posible clicar sobre algún otro botón en excel.

El código quiero poder detener es este:

  Sub Grafico()
Application.ScreenUpdating = True


  Dim wks As Worksheet
  'SE INDICA QUE SELECCIONE EL GRÁFICO DE LA HOJA DE CÁLCULO ACTIVA
  Set wks = ActiveWorkbook.Sheets(8)
  'wks.ChartObjects("Gráfico 1").Select
DoEvents


Dim Inicial, Final, delta As Date



delta = Hoja8.Range("C3").Value
Inicial = Hoja8.Range("C1").Value
Final = Hoja8.Range("C2").Value

Do While Hoja8.Range("a3") <> 8
Application.Wait (Now + TimeValue("00:00:01"))
Inicial = Inicial + delta
Hoja8.Range("C1") = Inicial
'Application.Wait (Now + TimeValue("00:00:02"))
'
DoEvents

Final = Inicial + delta
Hoja8.Range("C2") = Final
'Application.Wait (Now + TimeValue("00:00:01"))

DoEvents
'ActiveWorkbook.RefreshAll
Application.ScreenUpdating = True
'Stop
Application.Calculation = xlCalculationAutomatic
wks.ChartObjects("Gráfico 1").Activate
Application.ActiveChart.Refresh
Application.Wait (Now + TimeValue("00:00:02"))


'wks.ChartObjects("Gráfico 1").Activate

DoEvents

'Debug.Print "Final"
'Stop
Loop

End Sub

Muchas gracias a alguien que pueda darme alguna idea.

Featured Replies

publicado
  • Autor

@AntoniMil gracias. Lo adapte y me funciona perfecto. Pensaba, porque aunque ponía una línea con Do Events, excel me mostraba aspecto de estar bloqueado y de no poder dar click en otro botón, pero así me funciono perfecto.

 

Mil gracias por su ayuda.

Archivado

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.