Microsoft 365 Variable non définie

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 !

Usine à gaz

XLDnaute Barbatruc
Bonjour à toutes et à tous,
Je vous souhaite une belle journée 🙂

Je n'arrive pas à faire fonctionner cette ch'tite boucle ... nul je suis
Et je ne comprends pas pourquoi 😡

Je me permets de vous vous soumettre mon code (qui est dans ma feuille) :
VB:
Option Explicit
'CreateObject("wscript.shell").SendKeys "{F2}"
'CreateObject("wscript.shell").SendKeys "{ESC}"
'CreateObject("wscript.shell").SendKeys "% ~{UP 30}{LEFT 20}~"
Private Sub Worksheet_Activate()
    If Sheets("Table").Range("n4") = "ouvert" Then
    Application.EnableEvents = False
    Application.ScreenUpdating = False
    Sheets("Table").Select
    Application.EnableEvents = True
    Application.ScreenUpdating = True
    MsgBox ("L'affectation doit être terminée" & Chr(10) & "avant tout autre action" & Chr(10) & Chr(10) & "clic sur cellule ICI" & Chr(10) & "pour affecter votre appel")
    Exit Sub
    End If
   
    Application.ScreenUpdating = False
    Application.EnableEvents = False
    ActiveWindow.LargeScroll ToRight:=-1
    ActiveSheet.Unprotect Password:=""
    Range(Cells(1, 14), Cells(1, 1)).Select
    ActiveWindow.Zoom = True 'ActiveWindow.Zoom = 114
    [A5] = "=""Eblts     ""&""       clic = Tri"""
    ActiveWindow.DisplayHorizontalScrollBar = False
    Range([a6], Cells(Rows.Count, "a").End(xlUp)).RowHeight = 55
   
    Columns("N:N").Select
    With Selection.Font
        .Color = -16777024
        .TintAndShade = 0
    End With
   
'    For i = 6 To 10000
'        If Cells(i, 10) = "NPR" Then
'        Rows.RowHeight = 55
'        End If
'    Next i

'    For i = 6 To Range("J" & Rows.Count).End(xlUp).Row
'        If Cells(i, 10) = "NPR" Then
'        Rows.RowHeight = 0
'        End If
'    Next

    [c1].Select
    ActiveSheet.Protect Password:="", DrawingObjects:=True, Contents:=True, Scenarios:=True
     Application.ScreenUpdating = True
    Application.EnableEvents = True
End Sub
et la photo du beugue :
1636542555836.png

Pourriez-vous m'aider ?

Mille remerciements,
lionel 🙂
 
Dernière édition:
Solution
C
Salut Lionel,

Il suffit d'ajouter un test 😜
VB:
For i = 6 To Range("J" & Rows.Count).End(xlUp).Row
    If Cells(i, 10) = "NPR" or Cells(i, 10) = "RdV Fait" then Rows(i).Hidden = True
Next i

A+
Bonjour à toutes et à tous,
Je vous souhaite une belle journée 🙂

Je n'arrive pas à faire fonctionner cette ch'tite boucle ... nul je suis
Et je ne comprends pas pourquoi 😡

Je me permets de vous vous soumettre mon code (qui est dans ma feuille) :
VB:
Option Explicit
'CreateObject("wscript.shell").SendKeys "{F2}"
'CreateObject("wscript.shell").SendKeys "{ESC}"
'CreateObject("wscript.shell").SendKeys "% ~{UP 30}{LEFT 20}~"
Private Sub Worksheet_Activate()
    If Sheets("Table").Range("n4") = "ouvert" Then
    Application.EnableEvents = False
    Application.ScreenUpdating = False
    Sheets("Table").Select
    Application.EnableEvents = True
    Application.ScreenUpdating = True
    MsgBox ("L'affectation doit être terminée" & Chr(10) & "avant tout autre action" & Chr(10) & Chr(10) & "clic sur cellule ICI" & Chr(10) & "pour affecter votre appel")
    Exit Sub
    End If
 
    Application.ScreenUpdating = False
    Application.EnableEvents = False
    ActiveWindow.LargeScroll ToRight:=-1
    ActiveSheet.Unprotect Password:=""
    Range(Cells(1, 14), Cells(1, 1)).Select
    ActiveWindow.Zoom = True 'ActiveWindow.Zoom = 114
    [A5] = "=""Eblts     ""&""       clic = Tri"""
    ActiveWindow.DisplayHorizontalScrollBar = False
    Range([a6], Cells(Rows.Count, "a").End(xlUp)).RowHeight = 55
 
    Columns("N:N").Select
    With Selection.Font
        .Color = -16777024
        .TintAndShade = 0
    End With
 
'    For i = 6 To 10000
'        If Cells(i, 10) = "NPR" Then
'        Rows.RowHeight = 55
'        End If
'    Next i

'    For i = 6 To Range("J" & Rows.Count).End(xlUp).Row
'        If Cells(i, 10) = "NPR" Then
'        Rows.RowHeight = 0
'        End If
'    Next

    [c1].Select
    ActiveSheet.Protect Password:="", DrawingObjects:=True, Contents:=True, Scenarios:=True
     Application.ScreenUpdating = True
    Application.EnableEvents = True
End Sub
et la photo du beugue :
Regarde la pièce jointe 1121001
Pourriez-vous m'aider ?

Mille remerciements,
lionel 🙂
Bonjour à tous
En plus des instructions déjà données
Attention à la boucle.....
"Rows.RowHeight = 0" affecte toute la feuille
Si cela doit être la colonne J contenant "NPR"
Alors
Rows(i).RowHeight...
ou
Rows(i).Hidden = True
Selon.......
 
Dernière édition:
Re
Pour suivre Jacky67
Je dirais même plus, avec
VB:
For i = 6 To Range("J" & Rows.Count).End(xlUp).Row
    Rows(i).Hidden = Cells(i, 10) = "NPR"
Next i
On peux surement supprimer la boucle précédente
Code:
 For i = 6 To Range("J" & Rows.Count).End(xlUp).Row
        If Cells(i, 10) = "NPR" Then
        Rows.RowHeight = 55
        End If
    Next

Cordialement
 
Dernière édition:
Bonjour Jacky67,
Bonjour Efgé,
Alors là c'est trop fort 🙂
Vous avez répondu à ma question suivante avant que je la pose lol
D'abord Jacky67 complété par Efgé
Trop, Trop fort 😛
Vous êtes géniaux; mais ça, je le savais déjà,
Merci à vous deux,
lionel 🙂
 
Bonjour Jacky67, Efgé, le Forum,
Bon WE à toutes et à tous 🙂

Pourriez-vous encore m'aider pour ce code que vous m'avez donné ?
VB:
    For i = 6 To Range("J" & Rows.Count).End(xlUp).Row
    Rows(i).Hidden = Cells(i, 10) = "NPR"
    Next i
Je voudrais que les lignes soient "Hidden" dans les deux cas "NPR" et "RdV Fait"
Je ne sais pas le coder.

je vous remercie par avance,
Amicalement,
lionel,
 
Bonjour à tous
Je pense, mais peut-être me trompe-je que la propostion de BrunoM45 , que je salut, n'affiche pas les lignes qui ne comporteraient pas "RDV fail" ou "NPR"
Je propose
VB:
For i = 6 To Range("J" & Rows.Count).End(xlUp).Row
    Rows(i).Hidden = (Cells(i, 10) ="NPR" or Cells(i, 10) = "RdV Fait")
Next i

Non testé sur le fichier mais a verifier quand même...

Après on peut voir
Code:
For i = 6 To Range("J" & Rows.Count).End(xlUp).Row
    If Cells(i, 10) = "NPR" or Cells(i, 10) = "RdV Fait" then 
           Rows(i).Hidden = True
    Else
                     Rows(i).Hidden = False
   End IF
Next i

Cordialement
 
- 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
10
Affichages
455
  • Question Question
Microsoft 365 Probléme VBA
Réponses
8
Affichages
213
  • Question Question
XL 2021 VBA excel
Réponses
4
Affichages
45
Réponses
2
Affichages
361
Retour