2 macros qui commande dans un fichier deux feuilles différentes

Fermé
Sangler83 - 1 avril 2021 à 11:52
eriiic Messages postés 24571 Date d'inscription mardi 11 septembre 2007 Statut Contributeur Dernière intervention 8 mai 2024 - 1 avril 2021 à 19:42
Bonjour,

J'ai un fichier avec deux feuilles.
Au lieu de feuil 1 je l'ai nommée N
Au lieu de feuil 2 je l'ai nommée D

Comment faire pour que la 1ère en VBA travail seulement sur N et que la 2ème travaille sur D.

La 1ère et 2ème VBA sont de cette forme ci-dessous sauf quelle ne commande pas les mêmes colonnes.

Private Sub Worksheet_Change(ByVal Target As Range)
On Error Resume Next
' MAJUSCULE
If Target.Count > 1 Or Target.Value = "" Then Exit Sub
Application.EnableEvents = False
If Not Intersect(Target, Columns("D")) Is Nothing Then
Target = UCase(Target)
End If

If Not Intersect(Target, Columns("P")) Is Nothing Then
Target = UCase(Target)
End If

If Not Intersect(Target, Columns("R")) Is Nothing Then
Target = UCase(Target)
End If

If Not Intersect(Target, Columns("T")) Is Nothing Then
Target = UCase(Target)
End If


Application.EnableEvents = True ' facultatif
' Minuscule
If Target.Count > 1 Or Target.Value = "" Then Exit Sub
Application.EnableEvents = False

If Not Intersect(Target, Columns("G")) Is Nothing Then
Target = WorksheetFunction.Proper(Target.Value)
End If

If Not Intersect(Target, Columns("M")) Is Nothing Then
Target = WorksheetFunction.Proper(Target.Value)
End If

If Not Intersect(Target, Columns("N")) Is Nothing Then
Target = WorksheetFunction.Proper(Target.Value)
End If

If Not Intersect(Target, Columns("Q")) Is Nothing Then
Target = WorksheetFunction.Proper(Target.Value)
End If

If Not Intersect(Target, Columns("S")) Is Nothing Then
Target = WorksheetFunction.Proper(Target.Value)
End If

If Not Intersect(Target, Columns("U")) Is Nothing Then
Target = WorksheetFunction.Proper(Target.Value)
End If


Application.EnableEvents = True

End Sub

Pouvez-vous m'aider ?

Je suis en EXCEL 2007

Cordialement

Merci


Configuration: Windows / Firefox 87.0
A voir également:

1 réponse

eriiic Messages postés 24571 Date d'inscription mardi 11 septembre 2007 Statut Contributeur Dernière intervention 8 mai 2024 7 216
1 avril 2021 à 19:42
Bonjour,

Quel est ton problème ?
Vu que tu utilises l'événement Change, chaque macro travaille sur la feuille active qui ne peut être que la sienne.
Chaque module de feuille doit avoir sa macro avec les bons paramètres.
eric
0