| | Post: 82 | Registrato il: 06/07/2016
| Città: BOLZANO | Età: 31 | Utente Junior | 2010 | | OFFLINE | |
|
10/02/2018 16:27 | |
Un saluto a tutti
È possibile realizzare una macro che scopre e nasconde le forme ( shapes ) presenti nel foglio in relazione alla data contenuta nei vari range ?
esempio:
scopre la forma A se nel range C10:C25 è presente una data che corrisponde alla cella C5 (=oggi) e la rinasconde se la data non corrisponde , e faccia altrettanto con la forma B se è contenuta nel range C30 : C45 e con la forma C se compresa nel range C50 : C65
Grazie
saluti Marilena |
|
| | Post: 3.161 | Registrato il: 28/06/2011
| Città: AGORDO | Età: 70 | Utente Master | 2013 | | OFFLINE | |
|
10/02/2018 17:50 | |
L'allegato per me è rovinato, dovrebbe essere così
Nota Bene, nel mio caso i nomi delle shapes sono (Rettangolo arrotondato 1) + (Ovale 2)
Il codice va inserito in Foglio1 e funziona ogni volta che modifichi D10:D25 + D30:D45
vb Sub Worksheet_Change(ByVal Target As Range)
Dim Area As Range, Rg As Object, DT As Date
DT = Date
If Not Intersect(Target, Range("D10:D25")) Is Nothing Then
Set Area = Sheets("Foglio1").Range("D10:D25")
Set Rg = Area.Find(DT, LookIn:=xlValues, LookAt:=xlWhole)
If Rg Is Nothing Then
Sheets("Foglio1").Shapes("Rettangolo arrotondato 1").Visible = False
Else
Sheets("Foglio1").Shapes("Rettangolo arrotondato 1").Visible = True
End If
Set Area = Nothing
Set Rg = Nothing
End If
If Not Intersect(Target, Range("D30:D45")) Is Nothing Then
Set Area = Sheets("Foglio1").Range("D30:D45")
Set Rg = Area.Find(DT, LookIn:=xlValues, LookAt:=xlWhole)
If Rg Is Nothing Then
Sheets("Foglio1").Shapes("Ovale 2").Visible = False
Else
Sheets("Foglio1").Shapes("Ovale 2").Visible = True
End If
Set Area = Nothing
Set Rg = Nothing
End If
End Sub [Modificato da raffaele1953 10/02/2018 20:12] Excel 2013 |
| | Post: 649 | Registrato il: 16/08/2015
| Città: CORDENONS | Età: 67 | Utente Senior | Excel 2016-32bit Win11 | | OFFLINE |
|
10/02/2018 18:27 | |
Un saluto a tutti.
Arrivo tardi ma ormai una macro l'ho scritta e pertanto l'allego. E' da mettere nel modulo "Questa_Cartella_Di_Lavoro (ThisWorkBook) in modo che si avvii ad ogni apertura del file:
Option Explicit
Private Sub Workbook_Open()
Dim data As Range
With Sheets(1)
For Each data In .Range("C10:C25")
If data = Range("C3") Then
.Shapes("Oval 4").Visible = True
Exit For
Else
.Shapes("Oval 4").Visible = False
End If
Next data
For Each data In .Range("C30:C45")
If data = Range("C3") Then
.Shapes("Heart 5").Visible = True
Exit For
Else
.Shapes("Heart 5").Visible = False
End If
Next data
For Each data In .Range("C50:C65")
If data = Range("C3") Then
.Shapes("Fumetto 3 6").Visible = True
Exit For
Else
.Shapes("Fumetto 3 6").Visible = False
End If
Next data
End With
End Sub
PS. Avevo toppato , tutti i .Visible = False e .Visible = True erano scambiati . Ora la macro è corretta. [Modificato da rollis13 11/02/2018 12:32]
______________________________________________________________
C'è chi fa le COSE a CASO e chi fa CASO alle COSE (Ignoto) |
| | Post: 82 | Registrato il: 06/07/2016
| Città: BOLZANO | Età: 31 | Utente Junior | 2010 | | OFFLINE | |
|
11/02/2018 11:38 | |
Grazie Raffaele Grazie Rollis
la soluzione che si aggiorna ad ogni apertura del file é perfetta
Una piccola domanda è fattibile aggiungere un pulsante intitolato “ AGGIORNA “
In modo che si possa rilanciare manualmente la macro nel caso che il file rimane aperto ?
Grazie
Buona Domenica
Marilena |
| | Post: 650 | Registrato il: 16/08/2015
| Città: CORDENONS | Età: 67 | Utente Senior | Excel 2016-32bit Win11 | | OFFLINE |
|
11/02/2018 12:39 | |
Puoi come sempre associare la macro "Workbook_Open" al pulsante. Per visualizzare la macro quando l'assegni devi temporaneamente togliere il "Private" altrimenti non sarà visibile nella lista.
Volendo, il "Private" lo puoi anche omettere dato che non inficia la funzionalità della macro stessa.
______________________________________________________________
C'è chi fa le COSE a CASO e chi fa CASO alle COSE (Ignoto) |
| | Post: 83 | Registrato il: 06/07/2016
| Città: BOLZANO | Età: 31 | Utente Junior | 2010 | | OFFLINE | |
|
12/02/2018 12:45 | |
Grazie Rollis ora è perfetta!
Saluti Marilena |
| | Post: 651 | Registrato il: 16/08/2015
| Città: CORDENONS | Età: 67 | Utente Senior | Excel 2016-32bit Win11 | | OFFLINE |
|
12/02/2018 23:15 | |
Grazie del riscontro
______________________________________________________________
C'è chi fa le COSE a CASO e chi fa CASO alle COSE (Ignoto) |
|
|