Salut salut!
En fait j'ai encore un tout petit problème :/
J'ai testé sur un fichier un peu plus gros, et il me sort le problème de l'espace pile insuffisant.
Je crois qu'il doit y avoir trop de boucles imbriquées dans la fonction "delimitilot".
Je précise que j'ai bien changé les dimensions :
Dim pl(250, 250)
Sub test()
Set ws1 = Worksheets("ImportResultat")
Erase pl
Dim ctrl(100)
For i = 1 To 250
For j = 1 To 250
If ws1.Cells(i, j) <> 0 Then
If i > maxi Then maxi = i
If j > maxj Then maxj = j
If pl(i, j) = 0 Then
npl = npl + 1
pl(i, j) = npl
ws1.Cells(i, j).Interior.ColorIndex = npl + 2
delimitilot ws1, i, j, npl
End If
End If
Next j
Next i
For k = 1 To npl
Worksheets.Add after:=Worksheets(Worksheets.Count)
Worksheets(Worksheets.Count).Name = "ilot" & k
Next k
For i = 1 To maxi
For j = 1 To maxj
If pl(i, j) <> 0 Then
ctrl(pl(i, j)) = ctrl(pl(i, j)) + 1
Sheets("ilot" & pl(i, j)).Cells(ctrl(pl(i, j)), 1) = ws1.Cells(i, j)
End If
Next j
Next i
End Sub
Sub delimitilot(ws1, i, j, npl)
For ik = -1 To 1
For jk = -1 To 1
If ik = 0 Or jk = 0 Then
ii = i + ik: jj = j + jk
If ii > 0 And jj > 0 And ii < (251) And jj < (251) Then
If ws1.Cells(ii, jj) <> 0 And pl(ii, jj) = 0 Then
pl(ii, jj) = npl
ws1.Cells(ii, jj).Interior.ColorIndex = npl + 2
delimitilot ws1, ii, jj, npl
End If
End If
End If
Next jk
Next ik
End Sub