l indice n appartient pas a la selection
bonjour je recois un mess d erreur:
erreur d'execution: '9'
l indice n appartient pas à la selection8O8O8O8O¨
mon code est le suivant:
Code:
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
| Dim numcol As Integer, numligne As Integer
Dim nbtotalligne As Integer
Dim nbtotalcol As Integer
Dim i As Integer
Dim d As Integer
Dim colat As Integer
Application.ScreenUpdating = False 'ici c est pour rendre inactif l affichage le travail de la macro
On Error GoTo erreur
Workbooks.Open Filename:="G:\Rapport stage\Organisation\Double et travail macro\Conversion xls\vegcdelux2l.xls"
Application.Workbooks("vegcdelux2l.xls").Activate
On Error GoTo 0 'pour dire de ne plus tenir compte du truc d erreur d avant si y en a pas eu
numcol = 1 'A MODIF
nbtotalligne = Compte_nb_lignes_non_caches(numcol)
colat = 46
MsgBox (nbtotalligne)
For i = 2 To nbtotalligne
If Worksheets("Sheet1").Cells(i, colat).Value = 0 Then ' et c est cette ligne qui me souligne:(:(:(:cry:
Worksheets("Sheet1").Cells(i, colat).Value = 7
End If |
je ne comprend pas bien les selection des cases dans les feuille xls pouvez vous si vous avez un truc qui explique me donner le lien.
merci d avance
netoyage ou simplification du code
Bonjour à tous, et merci :king:
Je viens vous poser une nouvelle question:
Comment simplifier le code tout en sachant que le programme marche comme il le doit. Cependant je pense qu il est simplifiable mais je suis pour l'instant demuni.
Code:
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 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
|
Dim numcol As Integer, numligne As Integer
Dim nbtotalligne As Integer
Dim nbtotalcol As Integer
Dim i As Integer
Dim d As Integer
Dim colat As Integer
Application.ScreenUpdating = False
Workbooks.Open Filename:=ThisWorkbook.Path & "\vegcdelux2l.xls"
Application.Workbooks("vegcdelux2l.xls").Activate
numcol = 1
nbtotalligne = Compte_nb_lignes_non_caches(numcol)
colat = 46
For i = 2 To nbtotalligne
If Worksheets("vegcdelux2l").Cells(i, colat).Value = 0 Then
If Worksheets("vegcdelux2l").Cells(i, colat + 1).Value Like "titi *" Then
Worksheets("vegcdelux2l").Cells(i, colat).Value = "'3"
ElseIf Worksheets("vegcdelux2l").Cells(i, colat + 1).Value Like "toto *" Then
Worksheets("vegcdelux2l").Cells(i, colat).Value = "'3"
ElseIf Worksheets("vegcdelux2l").Cells(i, colat + 1).Value Like "lolo *" Then
Worksheets("vegcdelux2l").Cells(i, colat).Value = "'3"
Else:
If Worksheets("vegcdelux2l").Cells(i, colat + 3).Value <> "" Then
Worksheets("vegcdelux2l").Cells(i, colat).Value = "'2"
Else
If Worksheets("vegcdelux2l").Cells(i, colat + 2).Value <> "" Then
Worksheets("vegcdelux2l").Cells(i, colat).Value = "'1"
Else
If Worksheets("vegcdelux2l").Cells(i, colat + 1).Value Like "* SA *" Then
Worksheets("vegcdelux2l").Cells(i, colat).Value = "'2"
ElseIf Worksheets("vegcdelux2l").Cells(i, colat + 1).Value Like "* SARL *" Then
Worksheets("vegcdelux2l").Cells(i, colat).Value = "'2"
Else
Worksheets("vegcdelux2l").Cells(i, colat).Value = "'1"
End If
End If
End If
End If
End If
Next i
ActiveWorkbook.Save
ActiveWorkbook.SaveAs Filename:=ThisWorkbook.Path & "\vecdelux.xls"
Application.Workbooks("vecdelux.xls").Close False
CreMAJCDES
Workbooks.Open Filename:=ThisWorkbook.Path & "\vevehlux2.xls"
ActiveWorkbook.SaveAs Filename:=ThisWorkbook.Path & "\vevehlux.xls"
CreMAJ
Application.ScreenUpdating = True
Exit Sub |