grazie 1000
marco g
Nel modulo di codice *DEL FOGLIO* dove
hai la cella(qui A1):
Private Sub Worksheet_Change(ByVal Target As Range)
With Target
If UCase(.Value) = "SI" Then
Call tuaMacro
End If
End With
End Sub
In questo caso digitando si o Si o SI o sI nella cella
A1 del foglio, esegui la macro.
Puoi anche definire un Range di celle per i tuoi si:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim rng As Range
Set rng = Range("A1:A5")
If Not Intersect(Target, rng) Is Nothing Then
With Target
If UCase(.Value) = "SI" Then
Call tuaMacro
End If
End With
End If
Set rng = Nothing
End Sub
Nel caso tu voglia invece eseguire il codice della macro
solo se nella cella trovi si:
Public Sub tuaMacro()
Dim sh As Worksheet
Set sh = Worksheets("Foglio1")
With sh
If UCase(.Range("A1").Value) = "SI" Then
'codice da eseguire
End If
End With
Set sh = Nothing
End Sub
--
---------------------------
Mauro Gamberini
http://www.riolab.org/
http://blog.maurogsc.eu/
http://social.microsoft.com/Forums/it-IT/officeit/threads
'nel modulo di classe del foglio
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Address = "$A$1" Then
If Target.Value = "SI" Then
'call tuaMacro
End If
End If
End Sub
saluti
r
--
Come e dove incollare il codice:
http://www.rondebruin.nl/code.htm
Il mio ultimo lavoro ...
http://excelvba.altervista.org/blog/index.php/Excel-VBA/UsedRange-eccezioni-e-alternative.html
"Mauro Gamberini" ha scritto:
> > esiste la possibilità di associare una macro ad una singola cella
> > ad esempio se digito in A1 SI eseguo una macro ma se in A1
> > digito no continuo come se nulla fosse successo???
> >
>
> Nel modulo di codice *DEL FOGLIO* dove
> hai la cella(qui A1):
>
a questa ....
> Private Sub Worksheet_Change(ByVal Target As Range)
> With Target
> If UCase(.Value) = "SI" Then
> Call tuaMacro
> End If
> End With
> End Sub
credo manchi qualcosa ...
>
> In questo caso digitando si o Si o SI o sI nella cella
> A1 del foglio, esegui la macro.
> Puoi anche definire un Range di celle per i tuoi si:
>
> Private Sub Worksheet_Change(ByVal Target As Range)
> Dim rng As Range
> Set rng = Range("A1:A5")
> If Not Intersect(Target, rng) Is Nothing Then
> With Target
> If UCase(.Value) = "SI" Then
> Call tuaMacro
> End If
> End With
> End If
> Set rng = Nothing
> End Sub
target potrebbe sempre essere un range di più
celle ... quindi entrambe andrebbero in errore
per es. cancellando due celle nel range a1:a5
>
> Nel caso tu voglia invece eseguire il codice della macro
> solo se nella cella trovi si:
>
questa ...
> Public Sub tuaMacro()
> Dim sh As Worksheet
> Set sh = Worksheets("Foglio1")
> With sh
> If UCase(.Range("A1").Value) = "SI" Then
> 'codice da eseguire
> End If
> End With
> Set sh = Nothing
> End Sub
>
la lascio stare :-)
LOL!
Mi gratterò...;-)
> target potrebbe sempre essere un range di più
> celle ... quindi entrambe andrebbero in errore
> per es. cancellando due celle nel range a1:a5
>
Vero, dimenticanza(fretta) mia.
With Target
If .Cells.Count = 1 Then
If UCase(.Value) = "SI" Then
Call tuaMacro
End If
End If
End With
> > sai che quando riesco ... mi piace farti le pulci ... :-)
> >
>
> LOL!
> Mi gratterò...;-)
:-)
ciao
r
proprio quello che volevo
marco g
Grazie a te per il riscontro.
Se hai problemi, per favore resta
sempre in questo thread. Grazie
--
---------------------------
Mauro Gamberini
http://www.riolab.org/
http://blog.maurogsc.eu/
http://social.microsoft.com/Forums/it-IT/excelit/threads