[VBA] erreur 13 - oui mais je sais pas pk

I folima Elda -  
tompols Messages postés 1325 Statut Contributeur -
Salutation,

J'ai créé un fichier excel pour un jeu. Régulièrement, je fais des mise à jour où j'ajoute ou retire des choses. Cependant, j'ai remarquer un truc très étrange. Dans mon code (présenté ci-dessous), lorsque "y" prends 3 lignes, il me mets erreur 13 alors que si je rajoute une 4e ligne, tout marche nickel. Quelqu'un pourrais m'aider?

chassis = Cells(3, 3)
PA = Cells(4, 5)
impulsion = Cells(10, 3)
warp = Cells(10, 5)
coque = Cells(5, 3)
bouclier = Cells(5, 5)
ion = Cells(6, 3)
laser = Cells(6, 5)
projectils = Cells(6, 7)
consoattak = Cells(3, 1)
indman = Cells(2, 1)

Dim Doublons As Object
Dim Cel As Range, Plage As Range
Dim I As Integer
Dim Temp
Set Doublons = CreateObject("Scripting.Dictionary")
Set Plage = Range("B16:B30")
For Each Cel In Plage
    If Cel <> "" Then Doublons.Item(Cel.Value) = Cel.Value
Next Cel
Temp = Application.Transpose(Doublons.items)


Derligne = Range("B65536").End(xlUp).Address
Derligne = Range(Derligne).Row

For I = 16 To Derligne
    y = y & Chr(149) & " " & Cells(I, 2) & " * " & Cells(I, 4) & Chr(13)
Next

    designCode = "[table cellpadding=""0"" cellspacing=""0"" border=""1"" width=""1000""]" & Chr(13)
    designCode = designCode + "[tr][td width=""90"" align=""center""][color=#0000ff][b]Chassis[/b][/color][/td][td width=""45"" align=""center""][color=#0000ff][b]PA[/b][/color][/td][td colspan=""2"" width=""75"" align=""center""][color=#0000ff][b]Impulsion[/b][/color][/td][td colspan=""2"" width=""75"" align=""center""][color=#0000ff][b]Warp[/b][/color][/td][td colspan=""2"" width=""75"" align=""center""][color=#0000ff][b]Structure[/b][/color][/td][td colspan=""2"" width=""75"" align=""center""][color=#0000ff][b]Bouclier[/b][/color][/td][td width=""160"" align=""center""][color=#0000ff][b]Indice conso/attaque[/b][/color][/td][td align=""center""][color=#0000ff][b]Indice maniabilité[/b][/color][/td][/tr]" & Chr(13)
    designCode = designCode + "[tr][td width=""90"" align=""center""][color=#ff0000]" & chassis & "[/color][/td][td width=""90"" align=""center""][color=#ff0000]" & PA & "[/color][/td][td colspan=""2"" width=""90"" align=""center""][color=#ff0000]" & impulsion & "[/color][/td][td colspan=""2"" width=""90"" align=""center""][color=#ff0000]" & warp & "[/color][/td][td colspan=""2"" width=""90"" align=""center""][color=#ff0000]" & coque & "[/color][/td][td colspan=""2"" width=""90"" align=""center""][color=#ff0000]" & bouclier & "[/color][/td][td width=""90"" align=""center""][color=#ff0000]" & consoattak & "[/color][/td][td width=""90"" align=""center""][color=#ff0000]" & indman & "[/color][/td][/tr]" & Chr(13)
    designCode = designCode + "[tr][td width=""90"" align=""center""][color=#0000ff][b]Ion[/b][/color][/td][td width=""90"" align=""center""][color=#0000ff][b]Laser[/b][/color][/td][td width=""90"" align=""center""][color=#0000ff][b]Projectiles[/b][/color][/td][/tr]" & Chr(13)
    designCode = designCode + "[tr][td width=""90"" align=""center""][color=#ff0000]" & ion & "[/color][/td][td width=""90"" align=""center""][color=#ff0000]" & laser & "[/color][/td][td width=""90"" align=""center""][color=#ff0000]" & projectils & "[/color][/td][/tr]" & Chr(13)
    designCode = designCode + "[tr][td width=""150"" align=""center""][color=#0000ff][b]Modules[/b][/color][/td][td width=""250""align=""center""][color=#ff0000]" & y & "[/color][/td][/tr]" & Chr(13)
    designCode = designCode + "[/table]" & Chr(13)

Dim MyData As DataObject
Set MyData = New DataObject
MyData.SetText designCode
MyData.PutInClipboard
End Sub
A voir également:

2 réponses

I folima Elda
 
Je up!
0
tompols Messages postés 1325 Statut Contributeur 435
 
Salut,
bon bah jviens de tester ton code sur un feuille bidon avec qqes valeurs, pas d'erreur (1,2,3 ou plus pour y)...
as-tu bien vérifié que le pb vient de y ? as-tu tenté le débogage pas ou pas ou en mettant des points d'arrêt ?
sinon essaie de poster un fichier exemple où le pb se produit, là je n'arrive pas à reproduire l'erreur.....
EDIT : en meme tps erreur 13 c'est une incompatibilité de type, vérifie bien tes déclarations de variables et les valeurs que tu stockes dedans....
0