| | Post: 2 | Registrato il: 25/10/2017
| Città: POMIGLIANO D'ARCO | Età: 44 | Utente Junior | 2010 | | OFFLINE | |
|
26/10/2017 09:49 | |
Ciao a tutti,
avrei questa esigenza, a seconda del dato che inserisco in una cella mi restituisce un valore, in un certo senso è come se fosse una formula "se" ma più elaborata.
carico un file di esempio.
grazie mille per la disponibilità
|
|
| | Post: 456 | Registrato il: 24/06/2015
| Città: CATANIA | Età: 80 | Utente Senior | Excel2019 | | OFFLINE |
|
26/10/2017 13:32 | |
Ciao
prova con le due macro che vedi sotto entrambe da inserire nel Modulo del Foglio interessato
Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)
Dim i As Long
If Not Intersect(Target, Columns("B:B")) Is Nothing Then 'casoA
If Target.Value = "NO" Then
For i = 3 To 7
Cells(Target.Row, i) = " - "
Next i
End If
ElseIf Not Intersect(Target, Columns("E:G")) Is Nothing Then 'casoB
If Cells(Target.Row, 3) = "SI" And Cells(Target.Row, 4) = "SI" Then
Application.EnableEvents = False
If Target.Column = 5 Then
Cells(Target.Row, 6) = " - ": Cells(Target.Row, 7) = " - "
ElseIf Target.Column = 6 Then
Cells(Target.Row, 5) = " - ": Cells(Target.Row, 7) = " - "
ElseIf Target.Column = 7 Then
Cells(Target.Row, 5) = " - ": Cells(Target.Row, 6) = " - "
End If
Application.EnableEvents = True
End If
ElseIf Not Intersect(Target, Columns("C:C")) Is Nothing Then 'casoC
If Target.Value = "NO" Then
For i = 4 To 7
Cells(Target.Row, i) = " - "
Next i
End If
End If
End Sub
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Not Intersect(Target, Columns("C:C")) Is Nothing Then
If Cells(Target.Row, 2) = "NO" Then
MsgBox "Attenzione." & vbLf & "Questa cella non è editabile.", 0 + 16, "Errore"
Exit Sub
End If
ElseIf Not Intersect(Target, Columns("D:G")) Is Nothing Then
If Cells(Target.Row, 2) = "NO" Or (Cells(Target.Row, 3) = "NO" And Cells(Target.Row, 2) = "SI") Then
MsgBox "Attenzione." & vbLf & "Questa cella non è editabile.", 0 + 16, "Errore"
Exit Sub
End If
End If
End Sub
Fai sapere. Ciao,
Mario |
| | Post: 2 | Registrato il: 25/10/2017
| Città: POMIGLIANO D'ARCO | Età: 44 | Utente Junior | 2010 | | OFFLINE | |
|
26/10/2017 15:25 | |
intanto grazie per la risposta, ho provato a inserire la macro ma non avviene nulla, non mi da errori, dove sbaglio?
grazie |
| | Post: 3.512 | Registrato il: 21/06/2013
| Città: NAPOLI | Età: 70 | Utente Master | Excel 365 | | OFFLINE |
|
26/10/2017 15:44 | |
Dove hai inserito le due mscro?
Allega il file con le macro inserite.
Alfredo |
| | Post: 3 | Registrato il: 25/10/2017
| Città: POMIGLIANO D'ARCO | Età: 44 | Utente Junior | 2010 | | OFFLINE | |
|
26/10/2017 15:50 | |
|
| | Post: 457 | Registrato il: 24/06/2015
| Città: CATANIA | Età: 80 | Utente Senior | Excel2019 | | OFFLINE |
|
26/10/2017 16:05 | |
Ciao
t'avevo detto
da inserire nel Modulo del Foglio interessato
Tu, invece, le hai inserite in un Modulo standard.
Quando sei nell'Editor di VBA fai doppio clic su Foglio1 (quello che vedi a sinistra); in questo foglio inserisci le macro e cancella quelle che avevi inserito.
Ciao,
Mario |
| | Post: 3.513 | Registrato il: 21/06/2013
| Città: NAPOLI | Età: 70 | Utente Master | Excel 365 | | OFFLINE |
|
26/10/2017 16:11 | |
Ciao Mario
Pensavo fossi al mare e mi sono permesso di intervenire io.
Ma tu pensi che questa frase
Da inserire nel Modulo del Foglio interessato
sia comprensibile ai più?
Un caro saluto.
Alfredo |
| | Post: 4 | Registrato il: 25/10/2017
| Città: POMIGLIANO D'ARCO | Età: 44 | Utente Junior | 2010 | | OFFLINE | |
|
26/10/2017 16:13 | |
chiedo scusa, nella fretta ho saltato questo passaggio. funziona che è una meraviglia..
grazie mille.
giovanni
|
| | Post: 459 | Registrato il: 24/06/2015
| Città: CATANIA | Età: 80 | Utente Senior | Excel2019 | | OFFLINE |
|
26/10/2017 16:19 | |
Ciao
@giorunner
grazie per il riscontro.
Excel e VBA sono due prodotti "meravigliosi" ma hanno bisogno di molta, molta, molta attenzione.
@alfrimpa
Intanto hai fatto benissimo ad intervenire. Sono stato impegnato coi nipotini e poi quale mare ... da qualche giorno è agitato. Spero si calmi e per sabato ho ... una battuta di pesca (a bolentino non a traina).
Ciao,
Mario
|
| | Post: 3.514 | Registrato il: 21/06/2013
| Città: NAPOLI | Età: 70 | Utente Master | Excel 365 | | OFFLINE |
|
26/10/2017 16:20 | |
Allora buona mangiata di pesce
Alfredo |
|
|