Twitter iPhone pliant OnePlus 11 PS5 Disney+ Orange Livebox Windows 11

Nom ambigu détecté

6 réponses
Avatar
Peponne31
Bonsoir,

sur une page j'ai 2 fois la mème instruction et je suis en conflit. Est-il
possible de les réunir ?
voici la première instruction

Private Sub Worksheet_Change(ByVal Target As Range)
Application.ScreenUpdating = False
If Target.Address <> "$J$6" Then Exit Sub
ValideSaisie
End Sub

et la deuxième
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Column = Range("F1").Column And Target.Row > 20 And Target.Row <
51 Then
If Target = "m2" Or Target = "m3" Then
If MsgBox("Voulez calculer " & Target & " ??", vbYesNo) = vbYes Then
Sheets("Calcul_" & Target).Activate
End If
End If
End If
End Sub

je voudrais un seul:Private Sub Worksheet_Change(ByVal Target As Range)
pour ne pas avoir de conflit et réunir les 2 codes.
merci par avance si quelqu'un peut me dépanner.
Peponne31

6 réponses

Avatar
Philippe.R
Bonsoir,
Oui, tu peux (dois) à priori tout réunir dans une même sub

Private Sub Worksheet_Change(ByVal Target As Range)
Application.ScreenUpdating = False
If Target.Address <> "$J$6" Then Exit Sub
ValideSaisie
If Target.Column = Range("F1").Column And Target.Row > 20 And Target.Row <
51 Then
If Target = "m2" Or Target = "m3" Then
If MsgBox("Voulez calculer " & Target & " ??", vbYesNo) = vbYes Then
Sheets("Calcul_" & Target).Activate
End If
End If
End If
Application.ScreenUpdating = true
End Sub

--
Avec plaisir
http://dj.joss.free.fr/trombine.htm
http://jacxl.free.fr/mpfe/trombino.html
Philippe.R
Pour se connecter au forum :
http://www.excelabo.net/mpfe/connexion.php
News://news.microsoft.com/microsoft.public.fr.excel
"Peponne31" a écrit dans le message de
news:
Bonsoir,

sur une page j'ai 2 fois la mème instruction et je suis en conflit. Est-il
possible de les réunir ?
voici la première instruction

Private Sub Worksheet_Change(ByVal Target As Range)
Application.ScreenUpdating = False
If Target.Address <> "$J$6" Then Exit Sub
ValideSaisie
End Sub

et la deuxième
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Column = Range("F1").Column And Target.Row > 20 And Target.Row <
51 Then
If Target = "m2" Or Target = "m3" Then
If MsgBox("Voulez calculer " & Target & " ??", vbYesNo) = vbYes Then
Sheets("Calcul_" & Target).Activate
End If
End If
End If
End Sub

je voudrais un seul:Private Sub Worksheet_Change(ByVal Target As Range)
pour ne pas avoir de conflit et réunir les 2 codes.
merci par avance si quelqu'un peut me dépanner.
Peponne31





Avatar
Peponne31
Bonjour Philippe.R

merci de ta réponse mais ça ne fonctionne pas, je me demande si en ligne 3
Then
Exit Sub ne serai pas la cause de mon problème.

Private Sub Worksheet_Change(ByVal Target As Range)
Application.ScreenUpdating = False
If Target.Address <> "$J$6" Then Exit Sub
ValideSaisie
If Target.Column = Range("F1").Column And Target.Row > 20
AndTarget.Row <51 Then
If Target = "m2" Or Target = "m3" Then
If MsgBox("Voulez calculer " & Target & " ??", vbYesNo) =
vbYes Then
Sheets("Calcul_" & Target).Activate
End If
End If
End If
Application.ScreenUpdating = true
End Sub

Merci pour vos suggestoins.


Bonsoir,
Oui, tu peux (dois) à priori tout réunir dans une même sub

Private Sub Worksheet_Change(ByVal Target As Range)
Application.ScreenUpdating = False
If Target.Address <> "$J$6" Then Exit Sub
ValideSaisie
If Target.Column = Range("F1").Column And Target.Row > 20 And Target.Row <
51 Then
If Target = "m2" Or Target = "m3" Then
If MsgBox("Voulez calculer " & Target & " ??", vbYesNo) = vbYes Then
Sheets("Calcul_" & Target).Activate
End If
End If
End If
Application.ScreenUpdating = true
End Sub

--
Avec plaisir
http://dj.joss.free.fr/trombine.htm
http://jacxl.free.fr/mpfe/trombino.html
Philippe.R
Pour se connecter au forum :
http://www.excelabo.net/mpfe/connexion.php
News://news.microsoft.com/microsoft.public.fr.excel
"Peponne31" a écrit dans le message de
news:
Bonsoir,

sur une page j'ai 2 fois la mème instruction et je suis en conflit. Est-il
possible de les réunir ?
voici la première instruction

Private Sub Worksheet_Change(ByVal Target As Range)
Application.ScreenUpdating = False
If Target.Address <> "$J$6" Then Exit Sub
ValideSaisie
End Sub

et la deuxième
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Column = Range("F1").Column And Target.Row > 20 And Target.Row <
51 Then
If Target = "m2" Or Target = "m3" Then
If MsgBox("Voulez calculer " & Target & " ??", vbYesNo) = vbYes Then
Sheets("Calcul_" & Target).Activate
End If
End If
End If
End Sub

je voudrais un seul:Private Sub Worksheet_Change(ByVal Target As Range)
pour ne pas avoir de conflit et réunir les 2 codes.
merci par avance si quelqu'un peut me dépanner.
Peponne31









Avatar
Philippe.R
Re,
Fais l'essai en remplaçant :

If Target.Address <> "$J$6" Then Exit Sub
ValideSaisie
par :


If Target.Address = "$J$6" Then ValideSaisie
--
Avec plaisir
http://dj.joss.free.fr/trombine.htm
http://jacxl.free.fr/mpfe/trombino.html
Philippe.R
Pour se connecter au forum :
http://www.excelabo.net/mpfe/connexion.php
News://news.microsoft.com/microsoft.public.fr.excel
"Peponne31" a écrit dans le message de
news:
Bonjour Philippe.R

merci de ta réponse mais ça ne fonctionne pas, je me demande si en ligne 3
Then
Exit Sub ne serai pas la cause de mon problème.

Private Sub Worksheet_Change(ByVal Target As Range)
Application.ScreenUpdating = False
If Target.Address <> "$J$6" Then Exit Sub
ValideSaisie
If Target.Column = Range("F1").Column And Target.Row > 20
AndTarget.Row <51 Then
If Target = "m2" Or Target = "m3" Then
If MsgBox("Voulez calculer " & Target & " ??", vbYesNo) > vbYes Then
Sheets("Calcul_" & Target).Activate
End If
End If
End If
Application.ScreenUpdating = true
End Sub

Merci pour vos suggestoins.


Bonsoir,
Oui, tu peux (dois) à priori tout réunir dans une même sub

Private Sub Worksheet_Change(ByVal Target As Range)
Application.ScreenUpdating = False
If Target.Address <> "$J$6" Then Exit Sub
ValideSaisie
If Target.Column = Range("F1").Column And Target.Row > 20 And Target.Row
<
51 Then
If Target = "m2" Or Target = "m3" Then
If MsgBox("Voulez calculer " & Target & " ??", vbYesNo) = vbYes Then
Sheets("Calcul_" & Target).Activate
End If
End If
End If
Application.ScreenUpdating = true
End Sub

--
Avec plaisir
http://dj.joss.free.fr/trombine.htm
http://jacxl.free.fr/mpfe/trombino.html
Philippe.R
Pour se connecter au forum :
http://www.excelabo.net/mpfe/connexion.php
News://news.microsoft.com/microsoft.public.fr.excel
"Peponne31" a écrit dans le message
de
news:
Bonsoir,

sur une page j'ai 2 fois la mème instruction et je suis en conflit.
Est-il
possible de les réunir ?
voici la première instruction

Private Sub Worksheet_Change(ByVal Target As Range)
Application.ScreenUpdating = False
If Target.Address <> "$J$6" Then Exit Sub
ValideSaisie
End Sub

et la deuxième
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Column = Range("F1").Column And Target.Row > 20 And
Target.Row <
51 Then
If Target = "m2" Or Target = "m3" Then
If MsgBox("Voulez calculer " & Target & " ??", vbYesNo) = vbYes Then
Sheets("Calcul_" & Target).Activate
End If
End If
End If
End Sub

je voudrais un seul:Private Sub Worksheet_Change(ByVal Target As Range)
pour ne pas avoir de conflit et réunir les 2 codes.
merci par avance si quelqu'un peut me dépanner.
Peponne31











Avatar
Peponne31
Re

merci encore pour ta suggestion mais le programme plante, il tourne en boucle.
Si tu as une autre idée, je suis preneur.
Merci encore.
Peponne31



Re,
Fais l'essai en remplaçant :

If Target.Address <> "$J$6" Then Exit Sub
ValideSaisie
par :


If Target.Address = "$J$6" Then ValideSaisie
--
Avec plaisir
http://dj.joss.free.fr/trombine.htm
http://jacxl.free.fr/mpfe/trombino.html
Philippe.R
Pour se connecter au forum :
http://www.excelabo.net/mpfe/connexion.php
News://news.microsoft.com/microsoft.public.fr.excel
"Peponne31" a écrit dans le message de
news:
Bonjour Philippe.R

merci de ta réponse mais ça ne fonctionne pas, je me demande si en ligne 3
Then
Exit Sub ne serai pas la cause de mon problème.

Private Sub Worksheet_Change(ByVal Target As Range)
Application.ScreenUpdating = False
If Target.Address <> "$J$6" Then Exit Sub
ValideSaisie
If Target.Column = Range("F1").Column And Target.Row > 20
AndTarget.Row <51 Then
If Target = "m2" Or Target = "m3" Then
If MsgBox("Voulez calculer " & Target & " ??", vbYesNo) > > vbYes Then
Sheets("Calcul_" & Target).Activate
End If
End If
End If
Application.ScreenUpdating = true
End Sub

Merci pour vos suggestoins.


Bonsoir,
Oui, tu peux (dois) à priori tout réunir dans une même sub

Private Sub Worksheet_Change(ByVal Target As Range)
Application.ScreenUpdating = False
If Target.Address <> "$J$6" Then Exit Sub
ValideSaisie
If Target.Column = Range("F1").Column And Target.Row > 20 And Target.Row
<
51 Then
If Target = "m2" Or Target = "m3" Then
If MsgBox("Voulez calculer " & Target & " ??", vbYesNo) = vbYes Then
Sheets("Calcul_" & Target).Activate
End If
End If
End If
Application.ScreenUpdating = true
End Sub

--
Avec plaisir
http://dj.joss.free.fr/trombine.htm
http://jacxl.free.fr/mpfe/trombino.html
Philippe.R
Pour se connecter au forum :
http://www.excelabo.net/mpfe/connexion.php
News://news.microsoft.com/microsoft.public.fr.excel
"Peponne31" a écrit dans le message
de
news:
Bonsoir,

sur une page j'ai 2 fois la mème instruction et je suis en conflit.
Est-il
possible de les réunir ?
voici la première instruction

Private Sub Worksheet_Change(ByVal Target As Range)
Application.ScreenUpdating = False
If Target.Address <> "$J$6" Then Exit Sub
ValideSaisie
End Sub

et la deuxième
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Column = Range("F1").Column And Target.Row > 20 And
Target.Row <
51 Then
If Target = "m2" Or Target = "m3" Then
If MsgBox("Voulez calculer " & Target & " ??", vbYesNo) = vbYes Then
Sheets("Calcul_" & Target).Activate
End If
End If
End If
End Sub

je voudrais un seul:Private Sub Worksheet_Change(ByVal Target As Range)
pour ne pas avoir de conflit et réunir les 2 codes.
merci par avance si quelqu'un peut me dépanner.
Peponne31















Avatar
Peponne31
Re Re

Pour + d'explications, je te fais parvenir un fichier en Ci-Joint.
LA commande ValideSaisie me renvoie en Sub ValideSaisie() pour la suite du
traitement et la, sa plante.

http://cjoint.com/?dEl2RrRYcK

Re mercie


Re,
Fais l'essai en remplaçant :

If Target.Address <> "$J$6" Then Exit Sub
ValideSaisie
par :


If Target.Address = "$J$6" Then ValideSaisie
--
Avec plaisir
http://dj.joss.free.fr/trombine.htm
http://jacxl.free.fr/mpfe/trombino.html
Philippe.R
Pour se connecter au forum :
http://www.excelabo.net/mpfe/connexion.php
News://news.microsoft.com/microsoft.public.fr.excel
"Peponne31" a écrit dans le message de
news:
Bonjour Philippe.R

merci de ta réponse mais ça ne fonctionne pas, je me demande si en ligne 3
Then
Exit Sub ne serai pas la cause de mon problème.

Private Sub Worksheet_Change(ByVal Target As Range)
Application.ScreenUpdating = False
If Target.Address <> "$J$6" Then Exit Sub
ValideSaisie
If Target.Column = Range("F1").Column And Target.Row > 20
AndTarget.Row <51 Then
If Target = "m2" Or Target = "m3" Then
If MsgBox("Voulez calculer " & Target & " ??", vbYesNo) > > vbYes Then
Sheets("Calcul_" & Target).Activate
End If
End If
End If
Application.ScreenUpdating = true
End Sub

Merci pour vos suggestoins.


Bonsoir,
Oui, tu peux (dois) à priori tout réunir dans une même sub

Private Sub Worksheet_Change(ByVal Target As Range)
Application.ScreenUpdating = False
If Target.Address <> "$J$6" Then Exit Sub
ValideSaisie
If Target.Column = Range("F1").Column And Target.Row > 20 And Target.Row
<
51 Then
If Target = "m2" Or Target = "m3" Then
If MsgBox("Voulez calculer " & Target & " ??", vbYesNo) = vbYes Then
Sheets("Calcul_" & Target).Activate
End If
End If
End If
Application.ScreenUpdating = true
End Sub

--
Avec plaisir
http://dj.joss.free.fr/trombine.htm
http://jacxl.free.fr/mpfe/trombino.html
Philippe.R
Pour se connecter au forum :
http://www.excelabo.net/mpfe/connexion.php
News://news.microsoft.com/microsoft.public.fr.excel
"Peponne31" a écrit dans le message
de
news:
Bonsoir,

sur une page j'ai 2 fois la mème instruction et je suis en conflit.
Est-il
possible de les réunir ?
voici la première instruction

Private Sub Worksheet_Change(ByVal Target As Range)
Application.ScreenUpdating = False
If Target.Address <> "$J$6" Then Exit Sub
ValideSaisie
End Sub

et la deuxième
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Column = Range("F1").Column And Target.Row > 20 And
Target.Row <
51 Then
If Target = "m2" Or Target = "m3" Then
If MsgBox("Voulez calculer " & Target & " ??", vbYesNo) = vbYes Then
Sheets("Calcul_" & Target).Activate
End If
End If
End If
End Sub

je voudrais un seul:Private Sub Worksheet_Change(ByVal Target As Range)
pour ne pas avoir de conflit et réunir les 2 codes.
merci par avance si quelqu'un peut me dépanner.
Peponne31















Avatar
Frédéric Sigonneau
Bonjour,

Tu n'as pas corrigé ta macro comme Philippe te l'as indiqué...
Par ailleurs, je trouve que tu te compliques un peu la vie pour définir la plage
F21:F50 qui t'intéresse.
Tes deux procédures peuvent se réunir dans celle-ci :

Private Sub Worksheet_Change(ByVal Target As Range)

If Target.Address = "$J$6" Then
ValideSaisie
ElseIf Not Intersect(Target, Range("F21:F50")) Is Nothing Then
If Target = "m2" Or Target = "m3" Then
If MsgBox("Voulez calculer " & Target & " ??", vbYesNo) = vbYes Then
Sheets("Calcul_" & Target).Activate
End If
End If
End If

End Sub

FS
---
Frédéric Sigonneau
http://frederic.sigonneau.free.fr

Re Re

Pour + d'explications, je te fais parvenir un fichier en Ci-Joint.
LA commande ValideSaisie me renvoie en Sub ValideSaisie() pour la suite du
traitement et la, sa plante.

http://cjoint.com/?dEl2RrRYcK

Re mercie


Re,
Fais l'essai en remplaçant :

If Target.Address <> "$J$6" Then Exit Sub
ValideSaisie
par :


If Target.Address = "$J$6" Then ValideSaisie
--
Avec plaisir
http://dj.joss.free.fr/trombine.htm
http://jacxl.free.fr/mpfe/trombino.html
Philippe.R
Pour se connecter au forum :
http://www.excelabo.net/mpfe/connexion.php
News://news.microsoft.com/microsoft.public.fr.excel
"Peponne31" a écrit dans le message de
news:
Bonjour Philippe.R

merci de ta réponse mais ça ne fonctionne pas, je me demande si en ligne 3
Then
Exit Sub ne serai pas la cause de mon problème.

Private Sub Worksheet_Change(ByVal Target As Range)
Application.ScreenUpdating = False
If Target.Address <> "$J$6" Then Exit Sub
ValideSaisie
If Target.Column = Range("F1").Column And Target.Row > 20
AndTarget.Row <51 Then
If Target = "m2" Or Target = "m3" Then
If MsgBox("Voulez calculer " & Target & " ??", vbYesNo) >>> vbYes Then
Sheets("Calcul_" & Target).Activate
End If
End If
End If
Application.ScreenUpdating = true
End Sub

Merci pour vos suggestoins.


Bonsoir,
Oui, tu peux (dois) à priori tout réunir dans une même sub

Private Sub Worksheet_Change(ByVal Target As Range)
Application.ScreenUpdating = False
If Target.Address <> "$J$6" Then Exit Sub
ValideSaisie
If Target.Column = Range("F1").Column And Target.Row > 20 And Target.Row
<
51 Then
If Target = "m2" Or Target = "m3" Then
If MsgBox("Voulez calculer " & Target & " ??", vbYesNo) = vbYes Then
Sheets("Calcul_" & Target).Activate
End If
End If
End If
Application.ScreenUpdating = true
End Sub

--
Avec plaisir
http://dj.joss.free.fr/trombine.htm
http://jacxl.free.fr/mpfe/trombino.html
Philippe.R
Pour se connecter au forum :
http://www.excelabo.net/mpfe/connexion.php
News://news.microsoft.com/microsoft.public.fr.excel
"Peponne31" a écrit dans le message
de
news:
Bonsoir,

sur une page j'ai 2 fois la mème instruction et je suis en conflit.
Est-il
possible de les réunir ?
voici la première instruction

Private Sub Worksheet_Change(ByVal Target As Range)
Application.ScreenUpdating = False
If Target.Address <> "$J$6" Then Exit Sub
ValideSaisie
End Sub

et la deuxième
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Column = Range("F1").Column And Target.Row > 20 And
Target.Row <
51 Then
If Target = "m2" Or Target = "m3" Then
If MsgBox("Voulez calculer " & Target & " ??", vbYesNo) = vbYes Then
Sheets("Calcul_" & Target).Activate
End If
End If
End If
End Sub

je voudrais un seul:Private Sub Worksheet_Change(ByVal Target As Range)
pour ne pas avoir de conflit et réunir les 2 codes.
merci par avance si quelqu'un peut me dépanner.
Peponne31