Ho solo bisogno di avere un paio di condizioni in più (5) poter colorare delle celle con lo stesso colore delle celle in cui occasionalmente viene inserito un valore
C'è un modo semplice per arrivarci?
Grazie.
Ciao
Moderatori: Anthony47, Flash30005
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
DataEntryR = "D1:E100" '<<< Area in cui si scrivono dati
CheckR = "A1:A100" '<<< Area in cui va cambiato il colore
If Intersect(Target, Range(DataEntryR)) Is Nothing Then Exit Sub
If Selection.Count > 1 Then Exit Sub
If Target.Value = "" Then Exit Sub
Application.EnableEvents = False
For Each Cella In Range(CheckR)
If Cella.Value = Target.Value Then Cella.Interior.ColorIndex = Target.Interior.ColorIndex
Next Cella
Application.EnableEvents = True
End SubDim TarAd As String
Private Sub Worksheet_Change(ByVal Target As Range)
'Exit Sub
DataEntryR = "D2:F100" '<<< Area in cui si scrivono dati
CheckR = "A1:A100" '<<< Area in cui va cambiato il colore
If Intersect(Target, Range(DataEntryR)) Is Nothing And Intersect(Target, Range(CheckR)) Is Nothing Then Exit Sub
Application.EnableEvents = False
CC1 = Range(DataEntryR).Range("A1").Column
RR1 = Range(DataEntryR).Range("A1").Row
CCC = Range(DataEntryR).Columns.Count
RRC = Range(DataEntryR).Rows.Count
Application.ScreenUpdating = False
Range(CheckR).Interior.ColorIndex = xlNone
For Each Cella In Range(CheckR)
For I = 1 To CCC
Range(DataEntryR).Range(Cells(RR1, I), Cells(RR1 + RRC - 1, I)).Select
If Cella.Value = "" Then Exit For
If Application.WorksheetFunction.CountIf(Range(DataEntryR).Range(Cells(RR1, I), Cells(RR1 + RRC - 1, I)), Cella.Value) > 0 Then
Cella.Interior.ColorIndex = Cells(RR1, CC1 + I - 1).Interior.ColorIndex
End If
Next I
Next Cella
Range(TarAd).Select
Application.EnableEvents = True
Application.ScreenUpdating = True
End Sub
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
TarAd = Target.Address
Target.Select
End SubIf Application.WorksheetFunction.CountIf(Range(DataEntryR).Range(Cells(1, I), Cells(RRC, I)), Cella.Value) > 0 ThenCheckR = Range("Check1").Address '<<< su Foglio1; ovviamente Check2 su Foglio2 e cosi' via...Anthony47 ha scritto:Bene...
Per il problema del Contr-y, semplicemente l' esecuzione della macro (appena cambia la selezione) rende inutilizzabile il "ripeti". Devi quindi ripetere il comando.
Se inserisci righe all' interno degli intervalli che abbiamo chiamato DataEntryR e CheckR, allora io suggerisco di assegnare in ogni foglio dei "nomi" a questi intervalli, e poi nella macro usare questi nomi invece dei valori definiti tramite le due variabili; altrimenti devi modificare il vba a ogni inserimento riga.
Ciao.
Torna a Applicazioni Office Windows
| Mantenere la stessa formattazione con Errore Autore: danibi60 |
Forum: Applicazioni Office Windows Risposte: 5 |
| Problema con copia dati senza formattazione Autore: systemcrack |
Forum: Applicazioni Office Windows Risposte: 9 |
Visitano il forum: Nessuno e 13 ospiti