XL 2016 Problème Macro XL2010 vers XL2016

R@chid

XLDnaute Barbatruc
Bonjour,
svp, j'ai ces deux macros qui fonctionnaient très bien avec la version 2010, maintenant que je suis passé à la version 2016, les macros posent problème et fonctionnent pas et étant nul en la matière je ne sais pas vraiment d'où vient le problème.

Macro 1 :
Sub AfficherOngletsEleves(Optional Factice As String)
Dim w As Worksheet, af As Variant
Application.ScreenUpdating = False
ActiveWorkbook.Unprotect Password:="MotDePasse"
For Each w In Worksheets
If w.Name = w.[C7] Then Problème sur cette ligne
If IsEmpty(af) Then af = Not w.Visible
w.Visible = af
End If
Next
ActiveWorkbook.Protect Password:="MotDePasse"
End Sub


Macro 2:
Sub AfficherOnglets(Optional Factice As String)
Dim w As Worksheet, af As Variant
Application.ScreenUpdating = False
ActiveWorkbook.Unprotect Password:="MotDePasse"
For Each w In Worksheets
If w.[B7] Like "*Nom*" And w.[C7] = "" Then
If IsEmpty(af) Then af = Not w.Visible
w.Visible = af
End If
Next
ActiveWorkbook.Protect Password:="MotDePasse"
End Sub


Je remercie d'avance M. Job75 qui m'a beaucoup aidé et qui m'a fait les macros.

et merci à tout le monde de l'attention que vous voudrez porter à ma question

Re : problème résolu tout seul, les macros ont été corrompues apparemment et je ne sais pas pourquoi.
Merci
 
Dernière édition:

Staple1600

XLDnaute Barbatruc
Bonsoir, le fil, le forum, R@chid ;)

Ta macro initiale fonctionne sur Excel 2013
A tout hasard, j'ai modifié ainsi (ça fonctionne aussi sur Excel 2013)
VB:
Sub AfficherOngletsEleves()
Dim w As Worksheet, af As Variant
Application.ScreenUpdating = False
ActiveWorkbook.Unprotect Password:="MotDePasse"
For Each w In Worksheets
If w.Name = w.Range("C7") Then
If IsEmpty(af) Then af = Not w.Visible
w.Visible = af
End If
Next
ActiveWorkbook.Protect Password:="MotDePasse"
End Sub

NB: Sub AfficherOnglets() fonctionne aussi sur Excel 2013.
J'ai laissé le Optional Factice As String
et tester la macro ainsi
VB:
Sub Test()
AfficherOnglets
End Sub
 
Dernière édition:

Discussions similaires

Réponses
3
Affichages
162

Statistiques des forums

Discussions
312 347
Messages
2 087 501
Membres
103 563
dernier inscrit
samyezzehar