come mio solito stavo procedendo a scrivere una macro, ma ecco che appena chiudo l'editor e faccio per eseguirla mi fa ritornare sull'editor nuovamente e, all'altezza di Sub Private Worksheet_Change, evidenziato in giallo, esce una finestra con scritto "Nome ambiguo Worksheet_Change"
Non vi nascondo che ho già un'altra Worksheet_Change nell'editor che opera in celle diverse rispetto alla seconda..
Ho cercato su internet le cause e, a quanto pare, questo problema succede nel momento in cui ci sta già un'altra worksheet change.
Non so che fare avete qualche suggerimento?
Grazie mille anticipatamente
Questi sono i codici:
- Codice: Seleziona tutto
Private Sub Worksheet_Change(ByVal Target As Range)
Application.EnableEvents = False
If Not Intersect(Target, Range("C13:D13")) Is Nothing Then
Cells(17, 1).Formula = "N/A"
Cells(18, 1).Formula = "N/A"
Cells(19, 1).Formula = "N/A"
Cells(20, 1).Formula = "N/A"
Cells(21, 1).Formula = "N/A"
Cells(17, 4).Formula = "N/A"
Cells(18, 4).Formula = "N/A"
Cells(19, 4).Formula = "N/A"
Cells(20, 4).Formula = "N/A"
Cells(21, 4).Formula = "N/A" ' uguale a Range("G2").Formula = "Visto"
ElseIf Not Intersect(Target, Range("A17:A21")) Is Nothing Then
Cells(13, 3).Formula = "See below" ' uguale a Range("K3").Formula = "Visto"
Cells(13, 4).Formula = "See below"
ElseIf Not Intersect(Target, Range("D17:D21")) Is Nothing Then
Cells(13, 3).Formula = "See below" ' uguale a Range("K3").Formula = "Visto"
Cells(13, 4).Formula = "See below"
End If
Application.EnableEvents = True
End Sub
'=========>>
Option Explicit
Option Compare Text
'--------->>
Private Sub Worksheet_Change(ByVal Target As Range)
Dim srcRng As Range
Dim destRng As Range, destRng2 As Range, destRng3 As Range
Const sIntervallo_Sorgente As String = "G10"
Const sIntervallo_Destinazione As String = "C28:C31"
Const sIntervallo_Destinazione2 As String = "D34:D43"
Const sIntervallo_Destinazione3 As String = "N10"
With Me
Set srcRng = .Range(sIntervallo_Sorgente)
Set destRng = .Range(sIntervallo_Destinazione)
Set destRng2 = .Range(sIntervallo_Destinazione2)
Set destRng3 = .Range(sIntervallo_Destinazione3)
End With
If Not Intersect(srcRng, Target) Is Nothing Then
Select Case srcRng.Value
Case "A", "B"
destRng.Value = "N/A"
Union(destRng2).ClearContents
Case "B", "Update", "Clinician review"
destRng2.Value = "0"
destRng.ClearContents
Case "C)"
destRng3.Value = "A"
Union(destRng).ClearContents
Case Else
Union(destRng, destRng2).ClearContents
End Select
End If
End Sub