Erreur d'execution 1004

skillipo Messages postés 29 Date d'inscription jeudi 23 novembre 2006 Statut Membre Dernière intervention 14 avril 2008 - 5 déc. 2007 à 12:09
jmfmarques Messages postés 7666 Date d'inscription samedi 5 novembre 2005 Statut Membre Dernière intervention 22 août 2014 - 6 déc. 2007 à 09:56
Bonjour,


j'ai une erreur d'execution 1004 voici mon code

<!-- BEGIN TEMPLATE: bbcode_code -->

Code :
<!--[if !IE]><--><!----><!--[endif]--><!--[if IE]>
<![endif]--> For i = LastLine To 8 Step -1 ' from the last line to line number 8
If xlApp.Application.WorksheetFunction.CountA(xlApp.Rows(i)) = 0 Then xlApp.Rows(i).Delete 'delete the Empty lines
If IsEmpty(Cells(B, i) And Cells(C, i) And Cells(D, i) And Cells(F, i) And Cells(H, i) And Cells(M, i) And Cells(N, i) And Cells(Q, i) And Cells(R, i) And Cells(S, i) And Cells(T, i) And Cells(U, i) And Cells(V, i)) Then sht.Range("X" & i).Value = "Error"
Next i

<!-- END TEMPLATE: bbcode_code -->

j'ai un erreur au niveau des multiple "AND" , je voudrais que si toute les cellules sont vide alors je rajoute ERROR .


Merci de votre aide

4 réponses

cs_casy Messages postés 7741 Date d'inscription mercredi 1 septembre 2004 Statut Membre Dernière intervention 24 septembre 2014 40
5 déc. 2007 à 12:21
A priori, je dirais que ce n'est pas If IsEmpty(Cells(B, i) And Cells(C, i) And ..... mais plutot If IsEmpty(Cells(B, i)) And IsEmpty(Cells(C, i)) And IsEmpty(Cells(D, i)) And ......

---- Sevyc64  (alias Casy) ----<hr size="2" width="100%" /># LE PARTAGE EST NOTRE FORCE #    http://aide-office-vba.monforum.com/index.php
0
skillipo Messages postés 29 Date d'inscription jeudi 23 novembre 2006 Statut Membre Dernière intervention 14 avril 2008
5 déc. 2007 à 13:58
'Suppression de ligne vide
    Dim LastLine As Long, i As Long

    LastLine = xlApp.ActiveSheet.UsedRange.Row - 1
    MsgBox "last line = " & LastLine
    LastLine = LastLine + xlApp.ActiveSheet.UsedRange.Rows.Count
    MsgBox "last line 2 = " & LastLine
    For i = LastLine To 8 Step -1 ' from the last line to line number 8
        MsgBox "Compteur =" & i
        If xlApp.Application.WorksheetFunction.CountA(xlApp.Rows(i)) = 0 Then xlApp.Rows(i).Delete 'delete the Empty lines
        If IsEmpty(Cells(B, i)) And IsEmpty(Cells(C, i)) And IsEmpty(Cells(D, i)) And IsEmpty(Cells(F, i)) And IsEmpty(Cells(H, i)) And IsEmpty(Cells(M, i)) And IsEmpty(Cells(N, i)) And IsEmpty(Cells(Q, i)) And IsEmpty(Cells(R, i)) And IsEmpty(Cells(S, i)) And IsEmpty(Cells(T, i)) And IsEmpty(Cells(U, i)) And IsEmpty(Cells(V, i)) Then MsgBox "Ligne numero : " & i    'sht.Range("X" & i).Value = "Error"
    Next i

j'ai essyé comme ca mais ca ne fonctionne pas non plu.

Merci
0
jmfmarques Messages postés 7666 Date d'inscription samedi 5 novembre 2005 Statut Membre Dernière intervention 22 août 2014 27
6 déc. 2007 à 09:38
D'instinct :

 If IsEmpty(Cells(B, i)) And IsEmpty(Cells(C, i)) And  ..... etc... ====>>>>   If (IsEmpty Cells(B, i) And IsEmpty(Cells(C, i) And    ---- etc ...) then....
0
jmfmarques Messages postés 7666 Date d'inscription samedi 5 novembre 2005 Statut Membre Dernière intervention 22 août 2014 27
6 déc. 2007 à 09:56
Juste une question à cent sous, maintenant :

Pourquoi ne pas faire ton test, plus simplement, sur la concaténation des contenus des cellules concernées ?
0
Rejoignez-nous