in un foglio ho una macro questa:
- Codice: Seleziona tutto
Private Sub Worksheet_Change(ByVal Target As Range)
'DISATTIVO LE APPLICATION PER VELOCIZZARE
'L'ESECUZIONE DELLA MACRO
Dim xlCal As XlCalculation
With Application
.ScreenUpdating = False
.EnableEvents = False
xlCal = .Calculation
.Calculation = xlCalculationManual
End With
Dim rLettera As Range
Dim rAreaCond As Range
Dim nUltB As Long
Dim sLettera As String
Dim cl As Range
Dim j As Long
UserForm1.Show vbModeless
DoEvents
If Target.Count = 1 Then
sLettera = Me.Range("C3").Value
If Not Intersect(Target, Me.Range("C3")) Is Nothing And sLettera <> "" Then
j = 6
nUltB = ultima(Foglio2.Range("B:B"))
Set rLettera = Foglio2.Range("B7:B" & nUltB)
Me.Range("b7:W" & Rows.Count).ClearContents
For Each cl In rLettera
Set rAreaCond = Foglio2.Range("M" & cl.Row & ":O" & cl.Row & _
",Q" & cl.Row & ":S" & cl.Row & ",U" & cl.Row & ":V" & cl.Row)
If cl.Value = sLettera And Application.WorksheetFunction.Count(rAreaCond) > 0 Then
j = j + 1
Foglio2.Range("b" & cl.Row, "W" & cl.Row).Copy
Me.Range("b" & j).PasteSpecial xlPasteValues
End If
Next cl
Me.Range("b7").Activate
Application.CutCopyMode = False
Set rLettera = Nothing
Set rAreaCond = Nothing
End If
End If
'--metto bianco sfondo--------------
Range("G7:H500").Select
With Selection.Interior
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
.ThemeColor = xlThemeColorDark1
.TintAndShade = 0
.PatternTintAndShade = 0
End With
Call separaorario
ActiveWindow.DisplayGridlines = False
'RIATTIVO LE APPLICATION
With Application
.Calculation = xlCal
.EnableEvents = True
.ScreenUpdating = True
End With
Unload UserForm1
End Sub
essa si avvia ogni volta cambio il valore in C3
ma si avvia anche quando scrivo in altre parti del foglio
(la relativa udf e' in un modulo)
ora ho la necessita di scrivere nello stesso foglio, quindi chiedo:
come posso modif la macro in modo si avvi solo se cambio il
valore in C3 e non si avvii se scrivo in altre celle del foglio stesso ?
mi potrebbe andare bene anche trasformarla in macro da mettere in un modulo
ed avviarla con pulsante.
grazie
ciao