Private Sub Exporter_Click() Sheets(1).valide End Sub
Sub valide() prepare = True End Subça marche, mais est-ce correct ?
Juste une question:
Peut-on gérer prepare = True depuis un bouton sur une autre feuille ?
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre questionOption Explicit Private sele As String, prepare As Boolean, last Private Sub Exporter_Click() prepare = False last = Range("A65536").End(xlUp).Row + 1 Sheets(1).Cells(last, 1).Select Dim e For Each e In Split(sele, "@") If e <> "" Then Range("A" & e).Font.ColorIndex = 0 Range("A" & e).Font.Bold = False ''Call ma macro d'exportation: row à prendre en compte e 'exemple: relevé des valeurs en colonne A de feuille 2 last = Sheets(2).Range("A65536").End(xlUp).Row + 1 Sheets(2).Cells(last, 1).Value = e 'sele "" End If Next Sheets(2).Select End Sub Private Sub Quitter_Click() prepare = False Sheets(1).Columns(1).Font.Bold = False Sheets(1).Columns(1).Font.ColorIndex = 0 last = Range("A65536").End(xlUp).Row + 1 Sheets(1).Cells(last, 1).Select sele = "" Sheets(2).Select End Sub Private Sub Worksheet_SelectionChange(ByVal Target As Range) 'If Not Intersect(Target, Rows(1)) Is Nothing Then Exit Sub 'If Not Intersect(Target, Rows(2)) Is Nothing Then Exit Sub If ActiveCell.Value = "" Then Exit Sub If prepare Then traitons Target End Sub Private Sub traitons(t As Range) Dim r As Range, tut As String For Each r In t.Rows If sele "" Then tut "@" Else tut = "" Select Case Range("A" & r.Row).Font.ColorIndex Case 3 Range("A" & r.Row).Font.ColorIndex = 0 Range("A" & r.Row).Font.Bold = False sele = Replace(sele, "@" & r.Row, "") Case Else Range("A" & r.Row).Font.ColorIndex = 3 Range("A" & r.Row).Font.Bold = True sele = sele & tut & r.Row & "@" End Select Next End Sub Sub valide() prepare = True End Sub
Private Sub Exporter_Click() Sheets(1).valide Sheets(1).Select End Sub
If Not Intersect(Target, Rows(1)) Is Nothing Then Exit Sub If Not Intersect(Target, Rows(2)) Is Nothing Then Exit Sub
Private Sub traitons(t As Range) Dim r As Range, tut As String Application.EnableEvents = False For Each r In t.Rows Dim yen_a As Range On Error Resume Next Set yen_a = Range("A" & r.Row & ":X" & r.Row).SpecialCells(xlCellTypeConstants) On Error GoTo 0 If Not yen_a Is Nothing Then Set yen_a = Nothing If sele "" Then tut "@" Else tut = "" Select Case Range("A" & r.Row).Font.ColorIndex Case 3 Range("A" & r.Row).Font.ColorIndex = 0 Range("A" & r.Row).Font.Bold = False sele = Replace(sele, "@" & r.Row, "") Case Else Range("A" & r.Row).Font.ColorIndex = 3 Range("A" & r.Row).Font.Bold = True sele = sele & tut & r.Row & "@" End Select End If Next Application.EnableEvents = True End Sub
If ActiveCell.Value = "" Then Exit Sub
Dim yen_a As Range On Error Resume Next Set yen_a = Range("A" & r.Row & ":X" & r.Row).SpecialCells(xlCellTypeConstants) On Error GoTo 0 If Not yen_a Is Nothing Then Set yen_a = Nothing
Application.EnableEvents = True
Private Sub Exporter_Click() prepare = true ' à la place de sheets(1).valide Sheets(1).Activate ' à la place de select (pour ne pas risquer de déclencher un "change" ' et utilise plutôt le nom de la feuille (sheets("nom_feuille"), ce qui te mettra à l'abri ' des conséquences d'un déplacement d'onglet End Sub
Sub valide() prepare = True End Sub
Option Explicit Private sele As String, prepare As Boolean, last
Option Explicit Private last as long
Public sele As String, prepare As Boolean Public Sub valide() prepare = True End Sub Public Sub changeetat() If ActiveSheet.Name <> "nom_feuille_où_sélections" Then Exit Sub ' <<<== 'remplace ce qu'il y a entre guillemets par le vrai nom de la feuille dédiée aux sélections prepare = Not prepare Dim mess As String If Not prepare Then MsgBox "vous venez de changer d'état et êtes maintenant en mode ""NORMAL""" & _ "dans ce mode, vous avez interrompu (sans la supprimer) temporairement la sélection " & vbCrLf & _ "Ce mode vous permet d'effectuer au besoin d'autre manoeuvres sans incidence sur la sélection" & _ "éventuellement en cours" & vbCrLf & vbCrLf & _ "N'oubliez pas, une fois terminées ces autres manoeuvres, de revenir au mode sélection " & _ "en pressant à nouveau la touche ESCAPE" Else MsgBox "Vous êtes de nouveau en mode ""SELECTION""" End If End Sub
Public Sub valide() prepare = True End Sub