XL 2013 Boucle

Usine à gaz

XLDnaute Barbatruc
Supporter XLD
Bonjour à toutes et à tous,

LOL, j'ose à peine poser ma question de crainte du retour de mon cher JM :)

J'ai un souci de boucle, voici mon code :
Code:
Sub Mise_a_jour_urgents()
    Application.EnableEvents = False
    Application.ScreenUpdating = False
    Application.Calculation = xlManual
    Sheets("SuivisAppels").Select
    For i = 7 To 50000
        ActiveSheet.Unprotect Password:=""
        If Cells(ActiveCell.Row, 20) < Now + 1 And Cells(ActiveCell.Row, 40) = 1 Then 'répondeurs à venir
        Cells(ActiveCell.Row, 37) = 1
        Cells(ActiveCell.Row, 40) = ""
        End If
        If Cells(ActiveCell.Row, 20) < Now + 1 And Cells(ActiveCell.Row, 39) = 1 Then 'à rappeler
        Cells(ActiveCell.Row, 36) = 1
        Cells(ActiveCell.Row, 39) = ""
        End If
        If Cells(ActiveCell.Row, 20) < Now + 1 And Cells(ActiveCell.Row, 38) = 1 Then 'ok rdv
        Cells(ActiveCell.Row, 33) = 1
        Cells(ActiveCell.Row, 38) = ""
        End If
    Next
    ActiveSheet.Protect Password:="", DrawingObjects:=True, Contents:=True, Scenarios:=True
    ActiveSheet.EnableSelection = xlNoRestrictions
    Application.EnableEvents = True
    Application.ScreenUpdating = True
    Application.Calculation = xlAutomatic
End Sub

Le code fonctionne mais il faut que je me trouve sur chaque ligne pour qu'il exécute.

Je cherche, je cherche mais ne trouve pas ce qui ne va pas.

Votre aide me serait salutaire comme d'hab.
Si un fichier test est nécessaire, je prendrai le temps d'en faire un.
Avec mes remerciements,
Bon dimanche à toutes et à tous.
Amicalement,
Lionel,
 

Staple1600

XLDnaute Barbatruc
Bonjour le fil, le forum

arthour973
Quelle est ta crainte?
Que je te dise que tu aurais pu joindre un fichier exemple, histoire ne pas perdre de temps à recréer un fichier existant sur ton disque dur?
Si oui, alors ta crainte était justifiée ;)
 

Staple1600

XLDnaute Barbatruc
Re

A vue de nez, mais non testé (puisque pas de fichier exemple...)
VB:
Sub Mise_a_jour_urgents()
    Application.EnableEvents = False
    Application.ScreenUpdating = False
    Application.Calculation = xlManual
    Sheets("SuivisAppels").Select
    For i = 7 To 50000
        ActiveSheet.Unprotect Password:=""
        If Cells(i, 20) < Now + 1 And Cells(i, 40) = 1 Then 'répondeurs à venir
        Cells(i, 37) = 1
        Cells(i, 40) = ""
        End If
        If Cells(i, 20) < Now + 1 And Cells(i, 39) = 1 Then 'à rappeler
        Cells(i, 36) = 1
        Cells(i, 39) = ""
        End If
        If Cells(i, 20) < Now + 1 And Cells(i, 38) = 1 Then 'ok rdv
        Cells(i, 33) = 1
        Cells(i, 38) = ""
        End If
    Next
    ActiveSheet.Protect Password:="", DrawingObjects:=True, Contents:=True, Scenarios:=True
    ActiveSheet.EnableSelection = xlNoRestrictions
    Application.EnableEvents = True
    Application.ScreenUpdating = True
    Application.Calculation = xlAutomatic
End Sub
 

Discussions similaires

Statistiques des forums

Discussions
312 095
Messages
2 085 249
Membres
102 836
dernier inscrit
Ali Belaachet