Notifications
Clear all

Problema num codigo

9 Posts
3 Usuários
0 Reactions
1,451 Visualizações
 gino
(@gino)
Posts: 0
New Member
Topic starter
 

Boas,

estou com um problema num codigo que fiz, quando o tento rodar aparece uma msg que diz "can't assign array" podem me dizer o que estou a fazer de mal?

obrigada

 
Postado : 24/02/2017 8:41 am
(@skulden)
Posts: 0
New Member
 

Uma coisa que você esta a fazer de mal é postar a dúvida sem o código pra gente olhar e ver o que está dando erro.

Infelizmente a gente não consegue saber o que acontece no seu código só de olhar pra mensagem do erro, muita coisa pode ocasionar ele.

Anexe a planilha zipada ou o código dentro de:

         

Abraços.

 
Postado : 24/02/2017 8:44 am
 gino
(@gino)
Posts: 0
New Member
Topic starter
 

Peco desculpa vou tentar postar aki o codigo.

 
Postado : 24/02/2017 8:50 am
(@fernandofernandes)
Posts: 43750
Illustrious Member
 

qual a linha do erro ?

 
Postado : 24/02/2017 8:56 am
 gino
(@gino)
Posts: 0
New Member
Topic starter
 

A parte em azul, "compteur" e isso que da erro!

 
Postado : 24/02/2017 9:04 am
(@fernandofernandes)
Posts: 43750
Illustrious Member
 

essa variável é declarada?

posso sugerir que vc cole seu código inteiro ao invés do print ?

 
Postado : 24/02/2017 9:59 am
 gino
(@gino)
Posts: 0
New Member
Topic starter
 

Sim esta declarada agora se esta bem ou nao isso e que nao sei.

Private Sub Label_rechercher_Click()
    
    
    Label_exporter.Visible = False
    
    compteur = -1
    
    If ComboBox_rech_groupe.ListIndex = -1 Then
        groupe = ""
    Else
        groupe = ComboBox_rech_groupe.Value
    End If
    nom = TextBox_rech_nom
    prenom = TextBox_rech_prenom
    entreprise = TextBox_rech_entreprise
    poste = TextBox_rech_poste
    Email = TextBox_rech_email

    der_ligne_bd = BD.Range("A1").End(xlDown).Row
    If der_ligne_bd > max_65000(65500) Then
        ListBox_resultats.List() = Array() 'Reset
        Label_ligne.Caption = "LIGNE"
        Exit Sub
    End If

    Dim tab_resultats()
    ReDim tab_resultats(der_ligne_bd - 2, 6)
    ReDim tab_listindex_to_ligne(der_ligne_bd - 2)
    
    For lig = 2 To der_ligne_bd
        
        If groupe = "" Then
            groupe_en_cours = ""
        Else
            groupe_en_cours = BD.Cells(lig, 1)
        End If
        
        If nom = "" Then
            nom_en_cours = ""
        Else
            nom_en_cours = BD.Cells(lig, 3)
        End If
        
        If prenom = "" Then
            prenom_en_cours = ""
        Else
            prenom_en_cours = BD.Cells(lig, 4)
        End If
        
        If entreprise = "" Then
            entreprise_en_cours = ""
        Else
            entreprise_en_cours = BD.Cells(lig, 5)
        End If
        
        If poste = "" Then
            poste_en_cours = ""
        Else
            poste_en_cours = BD.Cells(lig, 7)
        End If

        If Email = "" Then
            email_en_cours = ""
        Else
            email_en_cours = BD.Cells(lig, 22)
        End If

        If groupe_en_cours Like "*" & groupe & "*" And _
            nom_en_cours Like "*" & nom & "*" And _
            prenom_en_cours Like "*" & prenom & "*" And _
            entreprise_en_cours Like "*" & entreprise & "*" And _
            poste_en_cours Like "*" & poste & "*" And _
            email_en_cours Like "*" & Email & "*" Then 'Si OK
            
            compteur = compteur + 1
            
            tab_resultats(compteur, 0) = BD.Cells(lig, 1)
            tab_resultats(compteur, 1) = BD.Cells(lig, 3)
            tab_resultats(compteur, 2) = BD.Cells(lig, 4)
            tab_resultats(compteur, 3) = BD.Cells(lig, 5)
            tab_resultats(compteur, 4) = BD.Cells(lig, 7)
            tab_resultats(compteur, 5) = BD.Cells(lig, 22)
            tab_resultats(compteur, 6) = BD.Cells(lig, 20)
            
            tab_listindex_to_ligne(compteur) = lig

        End If
        
    Next

    'Résultats
    ListBox_resultats.ColumnCount = 7
    ListBox_resultats.ColumnWidths = "87;97;95;97;95;120"
    
    If compteur > -1 Then 'Si > 0 résultats
        
        Label_exporter.Visible = True
        
        If compteur = der_ligne_bd - 2 Then 'Si toute la BD
            ListBox_resultats.List() = tab_resultats
        Else
            
            Dim tab_resultats_2()
            ReDim tab_resultats_2(compteur, 6)
            
            For i = 0 To compteur
                tab_resultats_2(i, 0) = tab_resultats(i, 0)
                tab_resultats_2(i, 1) = tab_resultats(i, 1)
                tab_resultats_2(i, 2) = tab_resultats(i, 2)
                tab_resultats_2(i, 3) = tab_resultats(i, 3)
                tab_resultats_2(i, 4) = tab_resultats(i, 4)
                tab_resultats_2(i, 5) = tab_resultats(i, 5)
                tab_resultats_2(i, 6) = tab_resultats(i, 6)
            Next
            
            ListBox_resultats.List() = tab_resultats_2
            
        End If

        If Not IsEmpty(listindex_a_selectionner) Then
         
            If compteur >= listindex_a_selectionner Then
                ListBox_resultats.ListIndex = listindex_a_selectionner
            Else
                ListBox_resultats_Change
            End If
            
            listindex_a_selectionner = Empty
        
        Else
        
            ListBox_resultats_Change
        
        End If
        
    Else 'Si vide
    
        ListBox_resultats.List() = Array() 'Reset
        Label_ligne.Caption = "LIGNE"
        
    End If
    
    'Actu nb
    actualiser_nb_contacts_et_compteur
    
End Sub
 
Postado : 24/02/2017 10:31 am
(@fernandofernandes)
Posts: 43750
Illustrious Member
 

coloque logo abaixo da linha da Sub:

Dim compteur as Variant
 
Postado : 24/02/2017 1:04 pm
 gino
(@gino)
Posts: 0
New Member
Topic starter
 

MT obrigada, ficou resolvido.. eskesime de uma coisa dessas lol... ;)

 
Postado : 24/02/2017 1:28 pm