• Initiateur de la discussion Initiateur de la discussion chich
  • Date de début Date de début

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 !

chich

XLDnaute Occasionnel
Bonjour la communauté
je souhait savoir comment faire un test si la feuille ("GESTION DIVERS") est visible dans ma macro
Sub PREV( )
Dim c As Range
Application.ScreenUpdating = False
With Sheets("GESTION DIVERS")
For Each c In .Range(.[APl10], .[APl65536].End(xlUp))
If c.Value < DateSerial(Year(Date), Month(Date) + 3, Day(Date)) Then
If txt = "" Then txt = "Attention préavis fin de validitée(s):" & vbCrLf
txt = txt & c.Offset(, -2) & " " & c.Offset(, -1) & vbCrLf
End If
Next c
If txt <> "" Then MsgBox txt
End With
Application.ScreenUpdating = True
End Sub
merci
 
Bonjour Chich, bonjour le forum,

Essaie comme ça :

VB:
Sub PREV()
Dim c As Range
Application.ScreenUpdating = False

With Sheets("GESTION DIVERS")
  If .Visible = -1 Then '-1 si visible, 0 si masquée, 2 si très masquée (VeryHidden)
  For Each c In .Range(.[APl10], .[APl65536].End(xlUp))
  If c.Value < DateSerial(Year(Date), Month(Date) + 3, Day(Date)) Then
  If txt = "" Then txt = "Attention préavis fin de validitée(s):" & vbCrLf
  txt = txt & c.Offset(, -2) & " " & c.Offset(, -1) & vbCrLf
  End If
  Next c
  If txt <> "" Then MsgBox txt
  End If
End With
Application.ScreenUpdating = True
End Sub
 
Bonjour Chich, bonjour le forum,

Essaie comme ça :

VB:
Sub PREV()
Dim c As Range
Application.ScreenUpdating = False

With Sheets("GESTION DIVERS")
  If .Visible = -1 Then '-1 si visible, 0 si masquée, 2 si très masquée (VeryHidden)
  For Each c In .Range(.[APl10], .[APl65536].End(xlUp))
  If c.Value < DateSerial(Year(Date), Month(Date) + 3, Day(Date)) Then
  If txt = "" Then txt = "Attention préavis fin de validitée(s):" & vbCrLf
  txt = txt & c.Offset(, -2) & " " & c.Offset(, -1) & vbCrLf
  End If
  Next c
  If txt <> "" Then MsgBox txt
  End If
End With
Application.ScreenUpdating = True
End Sub
RE
Merci pour ton aide je voudrais que la macro ne s’exécute que si la feuille est visible
 
Re,

Ben Heu !... C'est que je t'ai proposé il me semble avec la conditionnelle
If .Visible = -1... End If. Si t'avais pris la peine de tester t'aurais vu !...
RE
Je te confirme j' ai plusieurs test la macro s'exécute même si la feuille et cacher j'appel (prev) dans une autre
macro d' attribution de droit d'accès au feuilles de mon classeur
Sub Workbook_Open()
Application.ScreenUpdating = False
Dim ws As Worksheet
For Each ws In ThisWorkbook.Worksheets
If ws.Name <> "ACCES" Then ws.Visible = xlSheetVeryHidden
Next ws
UserForm1.Show
Call PREV
Application.ScreenUpdating = True
End Sub
Sub PREV()
Dim c As Range
Application.ScreenUpdating = False
With Sheets("GESTION DIVERS")
If .Visible = -1 Then
End If
For Each c In .Range(.[APl10], .[APl65536].End(xlUp))
If c.Value < DateSerial(Year(Date), Month(Date) + 3, Day(Date)) Then
If txt = "" Then txt = "Attention préavis fin de validitée(s):" & vbCrLf
txt = txt & c.Offset(, -2) & " " & c.Offset(, -1) & vbCrLf
End If
Next c
If txt <> "" Then MsgBox txt
End With
Application.ScreenUpdating = True
End Sub
Option Explicit

Function VerifMDP(Utilisateur As String, MdP As String) As Boolean
Dim rngTrouve As Range
VerifMDP = False

With Sheets("parametrage")
Set rngTrouve = .Columns(1).Cells.Find(Utilisateur, lookat:=xlWhole)
If rngTrouve Is Nothing Then
VerifMDP = False
Else
If rngTrouve.Offset(0, 1) <> MdP Then
VerifMDP = False
Else
VerifMDP = True
End If
End If
End With
End Function
Sub AfficheFeuilles(Utilisateur As String)
Dim Col As Byte, i As Byte, Lig As Integer

With Sheets("parametrage") 'dans la feuille paramétrage
'comme on va boucler de la colonne 4 à la dernière colonne, on stocke le n° de la dern colonne :
Col = .Cells(1, .Cells.Columns.Count).End(xlToLeft).Column
'on cherche colonne A le nom d'utilisateur saisi et on stocke son num de ligne
Lig = .Columns(1).Cells.Find(Utilisateur, lookat:=xlWhole).Row
'boucle à partir de 3 car Feuil1 toujours affichée
For i = 3 To Col
If UCase(.Cells(Lig, i)) = "X" Then

Sheets(.Cells(1, i).Value).Visible = True 'on affiche la feuille

Else
Sheets(.Cells(1, i).Value).Visible = xlSheetVeryHidden 'sinon on la masque

End If
Next i
End With
End Sub
Sub test()
Sheets("parametrage").Visible = True
End Sub
 
- 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

  • Question Question
Microsoft 365 Problème de date
Réponses
5
Affichages
162
Réponses
5
Affichages
235
Réponses
7
Affichages
211
Réponses
2
Affichages
153
Réponses
4
Affichages
461
  • Question Question
XL 2021 VBA excel
Réponses
4
Affichages
169
Retour