Bonjour,
Merci ça marche avec redim
Le compilateur fourni le msg Erreur d'exécution 9 L'indice n'appartient pas á la sélection tandis que mon code semble cohérent pour la ligne suivante: PalindromeVector(k,j)=Vector(i,j)
Pouvez vous m'éclairer svp:
Function Palindrome(strTest As String) As Long
Dim temp As String
Dim i As Long
Palindrome = 0
For i = 1 To Len(strTest)
If Mid(strTest, i, 1) Like "[0-9A-Za-z]" Then
temp = temp & UCase(Mid(strTest, i, 1))
End If
Next i
If temp = StrReverse(temp) Then
Palindrome = 1
''MsgBox (temp + " est un palidrome")
End If
End Function
Sub PalindromesInVector()
Dim SheetLength As Long
Dim Sheetwidth As Long
Dim PalindromesCounter
PalindromesCounter = 0
SheetLength = Worksheets("Feuil1").UsedRange.Rows.Count
MsgBox (SheetLength)
Sheetwidth = Worksheets("Feuil1").UsedRange.Columns.Count
MsgBox (Sheetwidth)
ReDim Vector(SheetLength, Sheetwidth) As String
For i = 1 To SheetLength
For j = 1 To Sheetwidth
Vector(i, j) = Worksheets("Feuil1").Cells(i, j)
If Palindrome(Vector(i, j)) = 1 Then
PalindromesCounter = PalindromesCounter + 1
End If
Next
Next
Dim k As Long
MsgBox (PalindromesCounter)
ReDim PalindromeVector(PalindromeCounter, Sheetwidth) As String
k = 1
For i = 1 To SheetLength
For j = 1 To Sheetwidth
If Palindrome(Vector(i, j)) = 1 Then
MsgBox (k)
MsgBox (Vector(i, j))
PalindromeVector(k, j) = Vector(i, j)
k = k + 1
End If
Next
Next
For i = 1 To PalindromesCounter
Worksheets("Feuil3").Cells(i, 1) = PalindromeVector(i, 1)
Next
End Sub