1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
| Function isFree(ByVal pStartCol As String, ByVal pStartRow As Integer, ByVal pEndCol As String, ByVal pEndRow As Integer, pFile As String, pSheet As String) As Boolean
Dim free As Boolean '=> logique
'pStartCol => texte => colonne de début
'pStartRow => entier => ligne de début
'pEndCol => texte => colonne de fin
'pEndRow => entier => ligne de fin
'pFile => texte => nom fichier
'pSheet => texte => nom feuille
Application.Volatile
'recalcule la fonction à chaque calcul de la feuille
free = True
'free = Vrai
While (pStartCol <> pEndCol Or pStartRow <> pEndRow) And free = True
'tant que ni la ligne de fin, ni la colonne de fin ne sont atteiente et que free=vrai
If (Workbooks(pFile).Sheets(pSheet).Range(pStartCol & pStartRow).Cells.Interior.ColorIndex > 0 _
And Workbooks(pFile).Sheets(pSheet).Range(pStartCol & pStartRow).Cells.Interior.ColorIndex <> 2 _
And Workbooks(pFile).Sheets(pSheet).Range(pStartCol & pStartRow).Cells.Interior.ColorIndex <> 15) _
Then
'si dans le fichier(pfile) dans la feuille(psheet)
'la couleur de la cellule est blanche ou grise (à moins que ce ne soit pas la palette d'origine)
'alors
free = False
'free=faux
Else
'sinon
pStartCol = nextCol(pStartCol)
'colonne suivante
If (pStartCol = "B") Then
'si la colonne de départ est "B", alors (???)
pStartRow = pStartRow + 1
'on change de ligne (suivante)
End If
End If
Wend
'remonter au test de boucle
isFree = free
'la réponse = free
End Function |
Partager