Twitter iPhone pliant OnePlus 11 PS5 Disney+ Orange Livebox Windows 11

MEFC en VBA sur une plage variable sélectionnée

2 réponses
Avatar
Patrick BASTARD
Bonsoir à tou(te)s.

Mon problème :
Le code ci-dessous est sencé mettre une MEFC du type :
=$D$772>=Grande.Valeur(D$764:D$772;5)

Or, après exécution, je contrôle et je vois :
=$D$772>=Grande.Valeur(G$764:G$772;5)

Qui pourrait me dire où se situe l'erreur ?

D'avance merci.
==============================
Option Explicit
Dim PlG
Dim DeB
Dim FiN
Dim ZoN As Range
Dim c
Dim Mefc As Variant
Sub PlageSelection() 'A764:S772
Set PlG = Selection
With PlG
' PlG_Adresse = .Address
' Nbre_Lignes = .Item(PlG.Count).Row - .Item(1).Row
DeB = .Item(1).Row
FiN = .Item(PlG.Count).Row
End With

Set ZoN = Range(Range("D" & DeB), Range("D" & FiN))
ZoN.FormatConditions.Delete
For Each c In ZoN
' 1ère condition :
Mefc = "=" & c.Address & ">=" & "GRANDE.VALEUR(" _
& "D$" & ZoN.Item(1).Row & ":D$" & _
ZoN.Item(ZoN.Count).Row & ";5)"
c.FormatConditions.Add Type:=xlExpression, Formula1:=Mefc
c.FormatConditions(1).Interior.ColorIndex = 3

'...
Next c
End Sub
--
Bien amicordialement,
P. Bastard

2 réponses

Avatar
michdenis
Bonjour Patrick,

ceci est suffisant :

'--------------------------
Sub PlageSelection() 'A764:S772

Dim PlG As Range, C As Range

Set PlG = Range("D764:D772")
PlG.FormatConditions.Delete
For Each C In PlG
' 1ère condition :
Mefc = "=" & C.Address & ">=" & "GRANDE.VALEUR(" _
& "D$" & PlG.Item(1).Row & ":D$" & _
PlG.Item(PlG.Count).Row & ";5)"
C.FormatConditions.Add Type:=xlExpression, Formula1:=Mefc
C.FormatConditions(1).Interior.ColorIndex = 3

'...
Next C

End Sub
'--------------------------


Salutations!



"Patrick BASTARD" a écrit dans le message de news:
Bonsoir à tou(te)s.

Mon problème :
Le code ci-dessous est sencé mettre une MEFC du type :
=$D$772>=Grande.Valeur(D$764:D$772;5)

Or, après exécution, je contrôle et je vois :
=$D$772>=Grande.Valeur(G$764:G$772;5)

Qui pourrait me dire où se situe l'erreur ?

D'avance merci.
============================= Option Explicit
Dim PlG
Dim DeB
Dim FiN
Dim ZoN As Range
Dim c
Dim Mefc As Variant
Sub PlageSelection() 'A764:S772
Set PlG = Selection
With PlG
' PlG_Adresse = .Address
' Nbre_Lignes = .Item(PlG.Count).Row - .Item(1).Row
DeB = .Item(1).Row
FiN = .Item(PlG.Count).Row
End With

Set ZoN = Range(Range("D" & DeB), Range("D" & FiN))
ZoN.FormatConditions.Delete
For Each c In ZoN
' 1ère condition :
Mefc = "=" & c.Address & ">=" & "GRANDE.VALEUR(" _
& "D$" & ZoN.Item(1).Row & ":D$" & _
ZoN.Item(ZoN.Count).Row & ";5)"
c.FormatConditions.Add Type:=xlExpression, Formula1:=Mefc
c.FormatConditions(1).Interior.ColorIndex = 3

'...
Next c
End Sub
--
Bien amicordialement,
P. Bastard
Avatar
Fredo P
Bonsoir Patrick
Celle ci devrait être la bonne
Option Explicit

Dim PlG
Dim DeB
Dim FiN
Dim ZoN As Range
Dim c
Dim Mefc As Variant
Sub PlageSelection() 'A764:S772
Set PlG = Selection
With PlG
' PlG_Adresse = .Address
' Nbre_Lignes = .Item(PlG.Count).Row - .Item(1).Row
DeB = .Item(1).Row
FiN = .Item(PlG.Count).Row
End With

Set ZoN = Range(Range("D" & DeB), Range("D" & FiN))
ZoN.FormatConditions.Delete
For Each c In ZoN
' 1ère condition :ZoN.address
Mefc = "=" & c.Address & ">=" & "GRANDE.VALEUR(" _
& "D$" & ZoN.Row & ":D$" & _
ZoN(ZoN.Count).Row & ";5)"
c.FormatConditions.Add Type:=xlExpression, Formula1:=Mefc
c.FormatConditions(1).Interior.ColorIndex = 3

'...
Next c
End Sub
"Patrick BASTARD" a écrit dans le
message de news:
Bonsoir à tou(te)s.

Mon problème :
Le code ci-dessous est sencé mettre une MEFC du type :
=$D$772>=Grande.Valeur(D$764:D$772;5)

Or, après exécution, je contrôle et je vois :
=$D$772>=Grande.Valeur(G$764:G$772;5)

Qui pourrait me dire où se situe l'erreur ?

D'avance merci.
============================= > Option Explicit
Dim PlG
Dim DeB
Dim FiN
Dim ZoN As Range
Dim c
Dim Mefc As Variant
Sub PlageSelection() 'A764:S772
Set PlG = Selection
With PlG
' PlG_Adresse = .Address
' Nbre_Lignes = .Item(PlG.Count).Row - .Item(1).Row
DeB = .Item(1).Row
FiN = .Item(PlG.Count).Row
End With

Set ZoN = Range(Range("D" & DeB), Range("D" & FiN))
ZoN.FormatConditions.Delete
For Each c In ZoN
' 1ère condition :
Mefc = "=" & c.Address & ">=" & "GRANDE.VALEUR(" _
& "D$" & ZoN.Item(1).Row & ":D$" & _
ZoN.Item(ZoN.Count).Row & ";5)"
c.FormatConditions.Add Type:=xlExpression, Formula1:=Mefc
c.FormatConditions(1).Interior.ColorIndex = 3

'...
Next c
End Sub
--
Bien amicordialement,
P. Bastard