Saltar al contenido

error 28

publicado

Hola, tengo este pequeño código, pero... al ejecutarlo se me queda el puntero del ratón (en círculo)girando

y tengo que salir con CERRAR SESIÓN.

Podéis ayudarme de forma muy sencilla ? mi código es este:

Private Sub WorkSheet_Change(ByVal Target As Excel.Range)
If Range("$L$7").Value = "1" Then
Call Macro18
End If
End Sub
Sub Macro18()
Application.ScreenUpdating = False
Dim Str1 As String
Dim Str2 As String
Dim resultado1 As Long
Str1 = Range("C8")
Str2 = Range("L9")
resultado1 = StrComp(Str1, Str2, vbTextCompare)
Range("N9") = resultado1 + 1
Sheets("Hoja1").Select
Application.ScreenUpdating = True
Range("A1").Select
End Sub
 

Featured Replies

publicado

Hola

En general no es conveniente usar "Select" pero yendo a tu dilema, probablemente al insertar un valor en N9 se vuelve a activar el evento "Change" entrando en un bucle "infinito". Cambia así tu macro:

Sub Macro18()
Application.ScreenUpdating = False
Application.EnableEvents = False
Dim Str1 As String
Dim Str2 As String
Dim resultado1 As Long
Str1 = Range("C8")
Str2 = Range("L9")
resultado1 = StrComp(Str1, Str2, vbTextCompare)
Range("N9") = resultado1 + 1
Sheets("Hoja1").Select
Application.ScreenUpdating = True
Range("A1").Select
Application.EnableEvents = True
End Sub

Comentas

Abraham Valencia

publicado

Muchas Gracias.

publicado

Gracias, ahora tengo esto, Y ME FUNCIONA, pero...me sale Error 28 Espacio de pila insuficiente. Pero la macro funciona, solo que me sale el letrero (msgbox) y hasta que no lo pulso no se va, pero la macro funciona. Te envío el código:

Private Sub WorkSheet_Change(ByVal Target As Excel.Range)
If Range("$L$7").Value = "1" Then
Macro18
End If
End Sub
Sub Macro18()
Application.ScreenUpdating = False
Application.EnableEvents = False
Dim Str1 As String
Dim Str2 As String
Dim resultado1 As Long
Str1 = Range("C8")
Str2 = Range("L9")
resultado1 = StrComp(Str1, Str2, vbTextCompare)
Range("N9") = resultado1 + 1
Sheets("Hoja1").Select
Application.ScreenUpdating = True
Range("a1").Select
Application.EnableEvents = True
If Range("N9").Value = "1" Then
macro1
End If
End Sub

Sub macro1()
Range("J20").Value = "Debo poner esto funciona"
End Sub

publicado

En lugar de esto:

...
...
Application.EnableEvents = True
If Range("N9").Value = "1" Then
macro1
End If
End Sub

debe poner esto:

...
...
If Range("N9").Value = "1" Then
macro1
End If
Application.EnableEvents = True
End Sub

 

Archivado

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