Macro efface erreur et RechercheV

Boostez vos compétences Excel avec notre communauté !

Rejoignez Excel Downloads, le rendez-vous des passionnés où l'entraide fait la force. Apprenez, échangez, progressez – et tout ça gratuitement ! 👉 Inscrivez-vous maintenant !

Ken Hutchinson

XLDnaute Occasionnel
Bonjour le forum,


J'ai un tableau avec beaucoup de RechercheV. Ces recherches ramènent beaucoup d'erreur mais c'est normal.

Pour faire joli je lance une macro qui nettoie ce erreurs. Le problème est qu'elle est super longue car le tableau se recalcule à chaque fois.

Vous auriez une combine ?
voici le code :
Code:
Sub Efface_Erreur()



Sheets("recherche").Select
Range("k9").Select

For i = 9 To 372
    If IsError(ActiveCell) Then
    Selection.ClearContents
    End If
ActiveCell.Offset(1, 0).Select
Next i



End Sub
 
Re : Macro efface erreur et RechercheV

bonjour

Les select sont a eviter en Vba

Code:
Application.Calculation = xlCalculationManual
For i = 9 To 372
   If IsError(Sheets("recherche").Range("K" & i) Then   Sheets("recherche").Range("K" & i).ClearContents
Next i
Application.Calculation = xlCalculationAutomatic
End Sub
 
Re : Macro efface erreur et RechercheV

Sub Efface_Erreur()
Dim Cel As Range, Rng As Range, L As Long

With Application
.ScreenUpdating = False
.Calculation = xlCalculationManual
End With

With Sheets("recherche")
L = .Range("K65536").End(xlUp).Row
Set Rng = .Range("K9:K" & L)
End With
bonjour Ken

une possibilité

For Each Cel In Rng
If IsError(Cel) Then
Cel.ClearContents
End If
Next Cel

With Application
.ScreenUpdating = True
.Calculation = xlCalculationAutomatic
End With

Set Rng = Nothing

End Sub

à bientôt
 
Re : Macro efface erreur et RechercheV

oups,micmac et bonjour à Pierre Jean

Sub Efface_Erreur()
Dim Cel As Range, Rng As Range, L As Long

With Application
.ScreenUpdating = False
.Calculation = xlCalculationManual
End With

With Sheets("recherche")
L = .Range("K65536").End(xlUp).Row
Set Rng = .Range("K9:K" & L)
End With

For Each Cel In Rng
If IsError(Cel) Then
Cel.ClearContents
End If
Next Cel

With Application
.ScreenUpdating = True
.Calculation = xlCalculationAutomatic
End With

Set Rng = Nothing

End Sub

à bientôt
 
- Navigue sans publicité
- Accède à Cléa, notre assistante IA experte Excel... et pas que...
- Profite de fonctionnalités exclusives
Ton soutien permet à Excel Downloads de rester 100% gratuit et de continuer à rassembler les passionnés d'Excel.
Je deviens Supporter XLD

Discussions similaires

Réponses
9
Affichages
892
Réponses
21
Affichages
2 K
D
Réponses
4
Affichages
1 K
Dangdang
D
Réponses
2
Affichages
675
Réponses
7
Affichages
1 K
L
Réponses
9
Affichages
1 K
Retour