Bonjour a tous, j' ai un problème d'incompatibilité de type. En effet, mon programme me permet de copier 4 colonnes de nombres dans un workbook et de les coller dans un autre workbook. Le problème apparaît quand je modifie une colonne, par exemple je sélectionne toutes les cellules de la colonne à partir de la cinquième ligne, je copie et je colle dans la première cellule de ma colonne. Puis, je lance ma macro et là ça plante, ça m'affiche: "erreur d'éxecution '13', incompatibilité de type".
Voici mon code
While i <= 50
While j <= 20
If Cells(i, j).Value Like "*X*" And compteur = 1 Then
Cells(i + 3, j + 1).Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Copy
Workbooks(ThisWorkbook.Name).Worksheets("Raideurs").Activate
Cells(5, 2).Select
ActiveSheet.Paste
Selection.ClearFormats
compteur = 2
Workbooks(Fichier_a_ouvrir).Worksheets("Acoustique").Activate
j = 1
i = 1
End If
If Cells(i, j).Value Like "*Y*" And compteur = 2 Then
Cells(i + 3, j + 1).Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Copy
Workbooks(ThisWorkbook.Name).Worksheets("Raideurs").Activate
Cells(5, 3).Select
ActiveSheet.Paste
Selection.ClearFormats
compteur = 3
Workbooks(Fichier_a_ouvrir).Worksheets("Acoustique").Activate
j = 1
i = 1
End If
If Cells(i, j).Value Like "*Z*" And compteur = 3 Then
Cells(i + 3, j + 1).Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Copy
Workbooks(ThisWorkbook.Name).Worksheets("Raideurs").Activate
Cells(5, 4).Select
ActiveSheet.Paste
Selection.ClearFormats
compteur = 4
Workbooks(Fichier_a_ouvrir).Worksheets("Acoustique").Activate
j = 1
i = 1
End If
If Cells(i, j).Value = "Fréq Hz" And compteur = 4 Then
Cells(i + 1, j).Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Copy
Workbooks(ThisWorkbook.Name).Worksheets("Raideurs").Activate
Cells(5, 1).Select
ActiveSheet.Paste
Selection.ClearFormats
End If
j = j + 1
Wend
j = 1
i = i + 1
Wend
Merci de m'aider.
N'hésiter pas à me demander plus de précisions si je n'ai pas été assez clair.
Voici mon code
While i <= 50
While j <= 20
If Cells(i, j).Value Like "*X*" And compteur = 1 Then
Cells(i + 3, j + 1).Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Copy
Workbooks(ThisWorkbook.Name).Worksheets("Raideurs").Activate
Cells(5, 2).Select
ActiveSheet.Paste
Selection.ClearFormats
compteur = 2
Workbooks(Fichier_a_ouvrir).Worksheets("Acoustique").Activate
j = 1
i = 1
End If
If Cells(i, j).Value Like "*Y*" And compteur = 2 Then
Cells(i + 3, j + 1).Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Copy
Workbooks(ThisWorkbook.Name).Worksheets("Raideurs").Activate
Cells(5, 3).Select
ActiveSheet.Paste
Selection.ClearFormats
compteur = 3
Workbooks(Fichier_a_ouvrir).Worksheets("Acoustique").Activate
j = 1
i = 1
End If
If Cells(i, j).Value Like "*Z*" And compteur = 3 Then
Cells(i + 3, j + 1).Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Copy
Workbooks(ThisWorkbook.Name).Worksheets("Raideurs").Activate
Cells(5, 4).Select
ActiveSheet.Paste
Selection.ClearFormats
compteur = 4
Workbooks(Fichier_a_ouvrir).Worksheets("Acoustique").Activate
j = 1
i = 1
End If
If Cells(i, j).Value = "Fréq Hz" And compteur = 4 Then
Cells(i + 1, j).Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Copy
Workbooks(ThisWorkbook.Name).Worksheets("Raideurs").Activate
Cells(5, 1).Select
ActiveSheet.Paste
Selection.ClearFormats
End If
j = j + 1
Wend
j = 1
i = i + 1
Wend
Merci de m'aider.
N'hésiter pas à me demander plus de précisions si je n'ai pas été assez clair.