| | Post: 370 | Registrato il: 13/12/2015
| Città: MILANO | Età: 58 | Utente Senior | 2010 | | OFFLINE | |
|
14/10/2022 10:12 | |
Ciao a tutti.
Vorrei che se in B2 è presente il testo"Addetto/a Termo" le caselle di controllo 4 e 5 fossero visibili.
Altrimenti devono restare nascoste.
Il mio script:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim rng As Range
Dim c As Range
Set rng = Me.Range("B2")
If Not Intersect(Target, rng) Is Nothing Then
For Each c In Target
If c.Value = "Addetto/a Termo" Then
Me.OLEObjects("Casella di controllo 5").Visible = True
Else
Me.OLEObjects("Casella di controllo 4").Visible = True
End If
Next
End If
Set rng = Nothing End Sub
non è "gradito":
Ho provato anche a scrivere CheckBox5 ma il debug non gradisce comunque.
Grazie per l'aiuto.
[Modificato da BG66 14/10/2022 10:13] BG66
Excel 2010 |
|
| | Post: 1.018 | Registrato il: 24/06/2015
| Città: CATANIA | Età: 80 | Utente Veteran | Excel2019 | | OFFLINE |
|
14/10/2022 12:29 | |
Ciao Gene
Ma se vuoi che una rimanga sempre visibile e l'altra no, a seconda di cosa selezioni, allora prova così
Private Sub Worksheet_Change(ByVal Target As Range)
Dim rng As Range
Dim c As Range
Set rng = Me.Range("B2")
If Not Intersect(Target, rng) Is Nothing Then
For Each c In Target
If c.Value = "Addetto/a Termo" Then
'Me.OLEObjects("Casella di controllo 5").Visible = True
ActiveSheet.Shapes.Range(Array("Check Box 5")).Visible = True
ActiveSheet.Shapes.Range(Array("Check Box 4")).Visible = False
Else
'Me.OLEObjects("Casella di controllo 4").Visible = True
ActiveSheet.Shapes.Range(Array("Check Box 4")).Visible = True
ActiveSheet.Shapes.Range(Array("Check Box 5")).Visible = False
End If
Next
End If
Set rng = Nothing
End Sub
Ciao,
Mario |
| | Post: 370 | Registrato il: 13/12/2015
| Città: MILANO | Età: 58 | Utente Senior | 2010 | | OFFLINE | |
|
15/10/2022 05:15 | |
Ciao Mario,
ovviamente [RISOLTO].
Come mai hai usato Array ?
Gene BG66
Excel 2010 |
| | Post: 1.019 | Registrato il: 24/06/2015
| Città: CATANIA | Età: 80 | Utente Veteran | Excel2019 | | OFFLINE |
|
15/10/2022 05:49 | |
Ciao Gene
Perchè (credo) è la sintassi corretta per riferirsi ad una serie di Shapes.
Un'aggiunta. Io cambierei, nel caso la cella di riferimento fosse vuota, così:
....
If c.Value = "Addetto/a Termo" Then
'Me.OLEObjects("Casella di controllo 5").Visible = True
ActiveSheet.Shapes.Range(Array("Check Box 5")).Visible = True
ActiveSheet.Shapes.Range(Array("Check Box 4")).Visible = False
ElseIf c.Value = "Addetto/a Taglio" Then
'Me.OLEObjects("Casella di controllo 4").Visible = True
ActiveSheet.Shapes.Range(Array("Check Box 4")).Visible = True
ActiveSheet.Shapes.Range(Array("Check Box 5")).Visible = False
Else
ActiveSheet.Shapes.Range(Array("Check Box 4")).Visible = False
ActiveSheet.Shapes.Range(Array("Check Box 5")).Visible = False
End If
....
Ciao,
Mario
Ciao,
Mario
|
| | Post: 3.352 | Registrato il: 06/04/2013
| Utente Master | 2010 | | OFFLINE |
|
15/10/2022 10:02 | |
ciao
un caro saluto ad entrambi:
Gene:
OleObjects lo puoi utilizzare se la casella di controllo è presa dai controlli ActiveX mentre nel tuo caso è presa dai controlli modulo.
Per intenderci:
byby
Domenico
Win 10 - Excel 2016 |
| | Post: 371 | Registrato il: 13/12/2015
| Città: MILANO | Età: 58 | Utente Senior | 2010 | | OFFLINE | |
|
16/10/2022 11:11 | |
Ciao.
Voi due (@Marius44 e @dodo47) siete sempre fonte di insegnamento.
Grazie ancora.
Gene
BG66
Excel 2010 |
|
|