Re : bloquer des cellules en ecriture par macro
bonsoir au forum,
je reviens vers vous car j'ai le soucis d'une macro doublons qui ne fonctionne avec cette macro dans mon fichier.
Sub Efface()
ActiveSheet.Unprotect
Cells.Locked = True
With Range("B3:B20,D3
20,F3:F20,H3:H20,J3:J20,L3:L20,N3:N20,P3
20")
.Locked = False
.FormulaHidden = False
.ClearContents
Range("A1").Select
End With
ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True
End Sub
et la mcro qui ne fonctionne plus:
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
Dim plage As Range, n&, v, a1$, a2$
With Rows("3:" & Rows.Count)
.FormatConditions.Delete 'RAZ
.ClearComments
Set plage = Intersect(.Cells, Me.UsedRange)
End With
If plage Is Nothing Or ActiveCell = "" Then Exit Sub
If Intersect(ActiveCell, plage) Is Nothing Then Exit Sub
Cancel = True
With plage
n = Application.CountIf(.Cells, ActiveCell)
If n > 1 Then
v = Val(Application.Version)
a1 = IIf(v > 12, .Cells(1), ActiveCell).Address(0, 0) 'reférence relative
a2 = ActiveCell.Address 'référence absolue
.FormatConditions.Add xlExpression, _
Formula1:="=(" & a1 & "<>"""")*(" & a1 & "=" & a2 & ")"
.FormatConditions(1).Interior.ColorIndex = 6 'jaune
With ActiveCell.AddComment(n & " doublons")
With .Shape.TextFrame
.Characters.Font.Size = 11
.Characters.Font.ColorIndex = 2 'blanc
.Characters.Font.Bold = True 'gras
.AutoSize = True
.Parent.Fill.ForeColor.SchemeColor = 8 'fond noir
End With
.Visible = True
End With
End If
End With
End Sub
Comment puije l'adapter avec l'autre macro pour qu'elle fonctionne toutes les deux?
Merci pour votre aide