WILFRIED
XLDnaute Impliqué
Bonjour a tous et toutes,
après une recherche sur le forum concernant les variables de types tableaux dynamiques je pensait avoir réussit ma macro mais voila 1° utilisation :
avec une seul occurrence RAS,
2° utilisation , 2 occurrence là un message d'erreur :
erreur d'execution : '9'
l'indice n'appartient pas à la selection.
J'ai beau chercher dans tous les sens je ne vois pas où est mon erreur..😕
Si quellequ'un la voit..
Voici mon code :
Sub find_contact()
' Stop
Dim tab_contact() As Variant
fls_contact.Select
nb_sm_fiche = 0
For Each m_cell In rng_contact
' Stop
If Cbx_nm_contact.Value <> "tous" Then
If m_cell.Value = Cbx_nm_contact.Value Then
ReDim Preserve tab_contact(nb_sm_fiche, 22) 'As Variant
For i = 0 To 22
tab_contact(nb_sm_fiche, i) = m_cell.Offset(0, i - 3).Value
Next i
nb_sm_fiche = nb_sm_fiche + 1
End If
Else
End If
Next m_cell
Stop
Txt_nb_fiche.Text = nb_sm_fiche
'affichage du resultat
If nb_sm_fiche > 1 Then
SpinButton1.Visible = True
Else
SpinButton1.Visible = False
End If
For indic_tab_r = 0 To nb_sm_fiche - 1
For indic_tab_c = 0 To 11
Select Case indic_tab_c
Case 0
txt_code.Text = tab_contact(indic_tab_r, indic_tab_c)
Case 1
txt_dte.Text = tab_contact(indic_tab_r, indic_tab_c)
Case 2
txt_ref1.Text = tab_contact(indic_tab_r, indic_tab_c)
Case 3
Txt_nm.Text = tab_contact(indic_tab_r, indic_tab_c)
Case 4
Txt_ref2.Text = tab_contact(indic_tab_r, indic_tab_c)
Case 5
txt_ref3.Text = tab_contact(indic_tab_r, indic_tab_c)
Case 6
txt_ref4.Text = tab_contact(indic_tab_r, indic_tab_c)
Case 7
txt_ref5.Text = tab_contact(indic_tab_r, indic_tab_c)
Case 8
txt_ref6.Text = tab_contact(indic_tab_r, indic_tab_c)
Case 9
txt_ref7.Text = tab_contact(indic_tab_r, indic_tab_c)
Case 10
txt_ref8.Text = tab_contact(indic_tab_r, indic_tab_c)
Case 11
txt_ref9.Text = tab_contact(indic_tab_r, indic_tab_c)
Case Else
End Select
Next indic_tab_c
Next indic_tab_r
End Sub
indic_tab_c, indic_tab_r, nb_sm_fiche, sont déclarer en public sur un autre module.
Merci d'avance.
après une recherche sur le forum concernant les variables de types tableaux dynamiques je pensait avoir réussit ma macro mais voila 1° utilisation :
avec une seul occurrence RAS,
2° utilisation , 2 occurrence là un message d'erreur :
erreur d'execution : '9'
l'indice n'appartient pas à la selection.
J'ai beau chercher dans tous les sens je ne vois pas où est mon erreur..😕
Si quellequ'un la voit..
Voici mon code :
Sub find_contact()
' Stop
Dim tab_contact() As Variant
fls_contact.Select
nb_sm_fiche = 0
For Each m_cell In rng_contact
' Stop
If Cbx_nm_contact.Value <> "tous" Then
If m_cell.Value = Cbx_nm_contact.Value Then
ReDim Preserve tab_contact(nb_sm_fiche, 22) 'As Variant
For i = 0 To 22
tab_contact(nb_sm_fiche, i) = m_cell.Offset(0, i - 3).Value
Next i
nb_sm_fiche = nb_sm_fiche + 1
End If
Else
End If
Next m_cell
Stop
Txt_nb_fiche.Text = nb_sm_fiche
'affichage du resultat
If nb_sm_fiche > 1 Then
SpinButton1.Visible = True
Else
SpinButton1.Visible = False
End If
For indic_tab_r = 0 To nb_sm_fiche - 1
For indic_tab_c = 0 To 11
Select Case indic_tab_c
Case 0
txt_code.Text = tab_contact(indic_tab_r, indic_tab_c)
Case 1
txt_dte.Text = tab_contact(indic_tab_r, indic_tab_c)
Case 2
txt_ref1.Text = tab_contact(indic_tab_r, indic_tab_c)
Case 3
Txt_nm.Text = tab_contact(indic_tab_r, indic_tab_c)
Case 4
Txt_ref2.Text = tab_contact(indic_tab_r, indic_tab_c)
Case 5
txt_ref3.Text = tab_contact(indic_tab_r, indic_tab_c)
Case 6
txt_ref4.Text = tab_contact(indic_tab_r, indic_tab_c)
Case 7
txt_ref5.Text = tab_contact(indic_tab_r, indic_tab_c)
Case 8
txt_ref6.Text = tab_contact(indic_tab_r, indic_tab_c)
Case 9
txt_ref7.Text = tab_contact(indic_tab_r, indic_tab_c)
Case 10
txt_ref8.Text = tab_contact(indic_tab_r, indic_tab_c)
Case 11
txt_ref9.Text = tab_contact(indic_tab_r, indic_tab_c)
Case Else
End Select
Next indic_tab_c
Next indic_tab_r
End Sub
indic_tab_c, indic_tab_r, nb_sm_fiche, sont déclarer en public sur un autre module.
Merci d'avance.