
Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority |
' Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority |
.TintAndShade = 0 da errore
Sub inseriscirighe()
'
' Cerca un contenuto in una cella e poi aggiunge 5 righe sopra questa cella
'
' Toglie la protezione al foglio
' Sheets("PrimaNota").Unprotect Password:=""
For x = 1 To 5
Columns("A:A").Select
Range("A1").Activate
Selection.Find(What:="Saldi finali", After:=ActiveCell, LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False).Activate
riga = ActiveCell.Row
'riga = riga - 1
Range(Cells(riga, 1), Cells(riga, 1)).Activate
ActiveCell.EntireRow.Select
Selection.Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
rigaorig = riga + 1
Range("n4").Select
Selection.Copy
Range(Cells(riga, 7), Cells(riga, 7)).Select
ActiveSheet.Paste
Range("n3").Select
Selection.Copy
Range(Cells(riga, 10), Cells(riga, 10)).Select
ActiveSheet.Paste
Next x
' Protegge il foglio
' Sheets("PrimaNota").Protect Password:=""
' Elimina la formattazione condizionale perche nella copia si replicavano le regole
Cells.FormatConditions.Delete
' Reimposto la formattazione condizionale
Range(Cells(7, 1), Cells(rigaorig, 10)).Select
'Range("A5:H17").Select
Selection.FormatConditions.Add Type:=xlExpression, Formula1:= _
"=RESTO(RIF.RIGA(A5);2)=0"
'Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
With Selection.FormatConditions(1).Interior
.PatternColorIndex = xlAutomatic
.Color = 15524052
.TintAndShade = 0
End With
Selection.FormatConditions(1).StopIfTrue = False
Range(Cells(rigaorig, 1), Cells(rigaorig, 1)).Select
End Sub |
Sub inseriscirighe()
'
' Cerca un contenuto in una cella e poi aggiunge 5 righe sopra questa cella
'
' Toglie la protezione al foglio
' Sheets("PrimaNota").Unprotect Password:=""
For x = 1 To 1
Columns("A:A").Select
Range("A1").Activate
Selection.Find(What:="Saldi finali", After:=ActiveCell, LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False).Activate
riga = ActiveCell.Row
'riga = riga - 1
Range(Cells(riga, 1), Cells(riga, 1)).Activate
ActiveCell.EntireRow.Select
Selection.Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
rigaorig = riga + 1
Range("n4").Select
Selection.Copy
Range(Cells(riga, 7), Cells(riga, 7)).Select
ActiveSheet.Paste
Range("n3").Select
Selection.Copy
Range(Cells(riga, 10), Cells(riga, 10)).Select
ActiveSheet.Paste
Next x
' Elimina la formattazione condizionale perche nella copia si replicavano le regole
Cells.FormatConditions.Delete
' Reimposto la formattazione condizionale
Range(Cells(7, 1), Cells(rigaorig, 10)).Select
Selection.FormatConditions.Add Type:=xlExpression, Formula1:= _
"=RESTO(RIF.RIGA(A5);2)=0"
With Selection.FormatConditions(1).Interior
.PatternColorIndex = xlAutomatic
.Color = xlAutomatic
End With
Range(Cells(rigaorig, 1), Cells(rigaorig, 1)).Select
End Sub |
Sub inserisci_una_riga()
'
' Cerca un contenuto in una cella e poi aggiunge 5 righe sopra questa cella
'
' Toglie la protezione al foglio
' Sheets("PrimaNota").Unprotect Password:=""
Dim c As Range
Dim riga As Long
Dim rigaorig As Long
Set c = Range("A:A").Find(What:="Saldi finali", LookIn:=xlFormulas, LookAt:=xlPart, _
SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False)
If Not (c Is Nothing) Then
c.Activate
riga = c.Row
Cells(c.Row, "A").EntireRow.Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
rigaorig = riga + 1
Range("N4").Copy Cells(riga, 7)
Range("N3").Copy Cells(riga, 10)
End If
' Protegge il foglio
' Sheets("PrimaNota").Protect Password:=""
' Elimina la formattazione condizionale perche nella copia si replicavano le regole
Cells.FormatConditions.Delete
' Reimposto la formattazione condizionale
Set c = Range(Cells(7, 1), Cells(rigaorig, 10))
With c
.FormatConditions.Add Type:=xlExpression, Formula1:="=RESTO(RIF.RIGA(A5);2)=0"
.FormatConditions(.FormatConditions.Count).SetFirstPriority
With .FormatConditions(1).Interior
.PatternColorIndex = xlAutomatic
.Color = 15524052
End With
.FormatConditions(1).StopIfTrue = False
End With
Range(Cells(rigaorig, 1), Cells(rigaorig, 1)).Select
End Sub |
