OVH Cloud OVH Cloud

MEFC par VBA

2 réponses
Avatar
Florian
Bonjour
je souhaite mettre en ouevre une MEFC par VBA
J'ai un userfrom, avec des contrôles, lorsque j'envoie les éléments dans ma
feuille de calcul, je souhaite qu'à ce moment là, la MEFC se mette en place
Cela plante au niveau de la variable Mavar
Merci pour votre aide

Sub Macro1()
'Le nettoyage
Sheets("Travail").Select
Sheets("Travail").Unprotect Password:="toto"
Range("A" & ActiveCell.Row & ":AB" & ActiveCell.Row).Select

Mavar = ActiveCell.Row

Selection.FormatConditions.Add Type:=xlExpression, Formula1:="=$A&
Mavar<>"""""
With Selection.FormatConditions(1).Borders(xlLeft)
.LineStyle = xlContinuous
.Weight = xlHairline
.ColorIndex = 5
End With
With Selection.FormatConditions(1).Borders(xlRight)
.LineStyle = xlContinuous
.Weight = xlHairline
.ColorIndex = 5
End With
With Selection.FormatConditions(1).Borders(xlTop)
.LineStyle = xlContinuous
.Weight = xlHairline
.ColorIndex = 5
End With
With Selection.FormatConditions(1).Borders(xlBottom)
.LineStyle = xlContinuous
.Weight = xlHairline
.ColorIndex = 5
End With
End Sub

2 réponses

Avatar
LSteph
Bonjour,
pas trop regardé le reste mais ici:

Formula1:="=$A" & Mavar & "<>"""""

'lSteph

"Florian" a écrit dans le message de news:

Bonjour
je souhaite mettre en ouevre une MEFC par VBA
J'ai un userfrom, avec des contrôles, lorsque j'envoie les éléments dans
ma feuille de calcul, je souhaite qu'à ce moment là, la MEFC se mette en
place
Cela plante au niveau de la variable Mavar
Merci pour votre aide

Sub Macro1()
'Le nettoyage
Sheets("Travail").Select
Sheets("Travail").Unprotect Password:="toto"
Range("A" & ActiveCell.Row & ":AB" & ActiveCell.Row).Select

Mavar = ActiveCell.Row

Selection.FormatConditions.Add Type:=xlExpression, Formula1:="=$A&
Mavar<>"""""
With Selection.FormatConditions(1).Borders(xlLeft)
.LineStyle = xlContinuous
.Weight = xlHairline
.ColorIndex = 5
End With
With Selection.FormatConditions(1).Borders(xlRight)
.LineStyle = xlContinuous
.Weight = xlHairline
.ColorIndex = 5
End With
With Selection.FormatConditions(1).Borders(xlTop)
.LineStyle = xlContinuous
.Weight = xlHairline
.ColorIndex = 5
End With
With Selection.FormatConditions(1).Borders(xlBottom)
.LineStyle = xlContinuous
.Weight = xlHairline
.ColorIndex = 5
End With
End Sub



Avatar
Florian
Merci beaucoup Lsteph
Flo riant

"LSteph" a écrit dans le message de news:

Bonjour,
pas trop regardé le reste mais ici:

Formula1:="=$A" & Mavar & "<>"""""

'lSteph

"Florian" a écrit dans le message de news:

Bonjour
je souhaite mettre en ouevre une MEFC par VBA
J'ai un userfrom, avec des contrôles, lorsque j'envoie les éléments dans
ma feuille de calcul, je souhaite qu'à ce moment là, la MEFC se mette en
place
Cela plante au niveau de la variable Mavar
Merci pour votre aide

Sub Macro1()
'Le nettoyage
Sheets("Travail").Select
Sheets("Travail").Unprotect Password:="toto"
Range("A" & ActiveCell.Row & ":AB" & ActiveCell.Row).Select

Mavar = ActiveCell.Row

Selection.FormatConditions.Add Type:=xlExpression, Formula1:="=$A&
Mavar<>"""""
With Selection.FormatConditions(1).Borders(xlLeft)
.LineStyle = xlContinuous
.Weight = xlHairline
.ColorIndex = 5
End With
With Selection.FormatConditions(1).Borders(xlRight)
.LineStyle = xlContinuous
.Weight = xlHairline
.ColorIndex = 5
End With
With Selection.FormatConditions(1).Borders(xlTop)
.LineStyle = xlContinuous
.Weight = xlHairline
.ColorIndex = 5
End With
With Selection.FormatConditions(1).Borders(xlBottom)
.LineStyle = xlContinuous
.Weight = xlHairline
.ColorIndex = 5
End With
End Sub