N'ayant pas trouvé de réponse avec une MFC "classique" (voir https://forum.openoffice.org/fr/forum/v ... =4&t=61343), je tente ma chance avec une macro.
Il s'agit d'appliquer un style dans un tableau en parcourant une plage sous condition
Poser la question sous cette forme semble simple, mais je ne trouve pas la solution.
Le problème est que le style s'applique qu'à une seule cellule qui répond aux critères.
Voici la macro :
Code : Tout sélectionner
Sub Tour_jeux
Dim oEve, oPlage1, oPlage2, oPlage3, oCal, oParam as Object
Dim oDate1, oCell2, oCat, oCat_cal as Object
Dim i, j, n, k, col2 as Integer
Dim ligne1, ligne2, colonne as Integer
Dim sStyle1 as string
Dim sStyle2 as string
Dim sStyle3 as string
sStyle1 = "TD"
sStyle2 = "TR"
sStyle3 = "TN"
col2 = 16
oEve = ThisComponent.Sheets.getByName("Événements")
oCal = ThisComponent.Sheets.getByName("Calendrier")
oParam = ThisComponent.Sheets.getByName("Param")
' oPlage1 = oEve.getCellRangeByPosition(1, 1, 1 , 100)
' oPlage2 = oCal.getCellRangeByName("C5:AV40")
For n=1 To 50
oDate1 = oParam.getCellRangeByName("A"+col2)
oPlage1 = oEve.getCellByPosition(1, n)
oCat = oEve.getCellByPosition(3, n)
oCell2 = oCal.getCellByPosition(1+n,2+n)
If oCell2.value = oDate1.value AND oPlage1.String = "Tour régional" Then
For i=1 to 50
For j=1 to 15
oPlage2 = oCal.getCellByPosition(1+i,3+j)
oCat_cal= oCal.getCellByPosition(1,3+j)
If oPlage2.String <>"" AND oCat_cal.string = oCat.String Then
oPlage2.CellStyle = sStyle2
End If
Next j
Next i
End If
col2 = col2+1
Next n
End Sub
Merci par avance votre aide