Salut Jacques et le forum,
Merci beaucoup pour ta réponse Jacques ! Euh... en fait je débute un peu (beaucoup) avec VBA et je crois que je vais encore avoir besoin de ton aide 
J'ai bricolé un petit peu le code mais ça ne marche pas... J'ai placé le code dans 'ThisWorkbook' puis j'ai essayé de rajouter 'Sheets(i).' pour chercher dans toutes les feuilles, comme ça :
Set intTarget = Intersect(Target, Sheets(i).[A:A])
J'ai aussi essayé de modifier le message box comme ça :
1 2 3
| If VerifieSiExiste(Intersect([A1].CurrentRegion, Sheets(i).[A:A]), c) Then
MsgBox ("Déjà existant : " & c.Offset(0, -1) & "==>" & c
c.ClearContents & "voulez vous l'atteindre ",vbOKCancel )=vbOK |
Donc pour le moment le code ressemble à ça :
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
| Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
Dim intTarget As Range
Dim c As Range
' Tout d'abords sur modication colonne A on efface tout ce qu'il y as dans colonne b correspondante
Set intTarget = Intersect(Target, Sheets(i).[A:A]) 'Test si dans colonne A (on peu limiter les lignes concernées..')
If Not intTarget Is Nothing Then
'Sur modification dans colonne A on efface la B
intTarget.Offset(0, 1).ClearContents
Exit Sub
End If
Set intTarget = Intersect(Target, [B:B])
If Not intTarget Is Nothing Then
For Each c In intTarget
Debug.Print "traite " & c.Address
If VerifieSiExiste(Intersect([A1].CurrentRegion, Sheets(i).[A:A]), c) Then
MsgBox ("Déjà existant : " & c.Offset(0, -1) & "==>" & c
c.ClearContents & "voulez vous l'atteindre ",vbOKCancel )=vbOK
End If
Next
End If
End Sub |
Je me rends bien compte que j'ai dû faire plein d'erreurs, mais je ne vois pas comment faire... Arg !
Partager