Mon problème d'aujourd'hui me laisse perplexe.
J'ai créé un userform pour afficher et faire défiler les données d'une table
(pour rendre la consulation plus lisible).
j'y ai rajouté 2 boutons : + et - .
et c'est là que je commence à ne plus comprendre .
Quand je clic sur "-" la première fois tout se passe bien, il m'affiche la
ligne précédente. Puis après, il compte de 2 en 2. Je rate donc une ligne sur
2.
Quand je clic sur "+" en revanche, il ne se passe strictement rien alors que
j'ai l'impression de faire le même appel.
voici mon code :
Private Sub moins_Click()
Call afficher_inter(rech_service.Value, rech_inter.Value, False, True)
End Sub
Private Sub plus_Click()
Call afficher_inter(rech_service.Value, rech_inter.Value, True, False)
End Sub
Private Sub afficher_inter(ByVal S_service As String, ByVal S_inter As
String, ByVal plus As Boolean, ByVal moins As Boolean)
...
'2ème partie : on affiche l'intervention correspondante la plus récente
Worksheets("Temp").Activate
fin = Application.Sheets("Temp").Range("A1").End(xlDown).Row
ligneAffich2 = ActiveCell.Rows
If (moins = True And ligneAffich2 > 3 And ligneAffich2 <= fin) Then
ligneAffich2 = ligneAffich2 - 1
'ligneAffich2 = ActiveCell.Rows - 1
'MsgBox ("moins " & ligneAffich2)
Call afficher_ligne(ligneAffich2)
Range("A" & ligneAffich2).Select
End If
If (plus = True And ligneAffich2 < fin And ligneAffich2 >= 3) Then
ligneAffich2 = ligneAffich2 + 1
Call afficher_ligne(ligneAffich2)
Range("A" & ligneAffich2).Select
End If
If ((moins = False And plus = False) Or (ligneAffich2 < 3 Or ligneAffich2 >
fin)) Then
MsgBox ("sinon " & ligneAffich2)
Call afficher_ligne(fin)
Range("A" & fin).Select
End If
moins = False
plus = False
end sub
je vous épargne la première partie de la méthode, qui fonctionnne, ainsi que
la méthode affichage, qui ne fait que du remplissage de case.
Cette action est irreversible, confirmez la suppression du commentaire ?
Signaler le commentaire
Veuillez sélectionner un problème
Nudité
Violence
Harcèlement
Fraude
Vente illégale
Discours haineux
Terrorisme
Autre
isabelle
bonjour Julius,
je ne crois pas que ce soit une bonne idée de nommer un objet (bouton) et une variable (moins As Boolean) du même nom.
Private Sub CommandButton1_Click() Call afficher_inter(1, 0) End Sub
Private Sub CommandButton2_Click() Call afficher_inter(0, 1) End Sub
Private Sub afficher_inter(ByVal moins As Boolean, ByVal plus As Boolean) On Error Resume Next With UserForm1.ComboBox1 lgn = .ListIndex If moins Then UserForm1.ComboBox1.ListIndex = UserForm1.ComboBox1.ListIndex - 1 If plus Then UserForm1.ComboBox1.ListIndex = UserForm1.ComboBox1.ListIndex + 1 End With End Sub
isabelle
Bonjour et, bonne année tout le monde.
Mon problème d'aujourd'hui me laisse perplexe. J'ai créé un userform pour afficher et faire défiler les données d'une table (pour rendre la consulation plus lisible). j'y ai rajouté 2 boutons : + et - . et c'est là que je commence à ne plus comprendre .
Quand je clic sur "-" la première fois tout se passe bien, il m'affiche la ligne précédente. Puis après, il compte de 2 en 2. Je rate donc une ligne sur 2. Quand je clic sur "+" en revanche, il ne se passe strictement rien alors que j'ai l'impression de faire le même appel.
voici mon code :
Private Sub moins_Click() Call afficher_inter(rech_service.Value, rech_inter.Value, False, True) End Sub
Private Sub plus_Click() Call afficher_inter(rech_service.Value, rech_inter.Value, True, False) End Sub
Private Sub afficher_inter(ByVal S_service As String, ByVal S_inter As String, ByVal plus As Boolean, ByVal moins As Boolean)
...
'2ème partie : on affiche l'intervention correspondante la plus récente Worksheets("Temp").Activate fin = Application.Sheets("Temp").Range("A1").End(xlDown).Row ligneAffich2 = ActiveCell.Rows
If (moins = True And ligneAffich2 > 3 And ligneAffich2 <= fin) Then ligneAffich2 = ligneAffich2 - 1 'ligneAffich2 = ActiveCell.Rows - 1 'MsgBox ("moins " & ligneAffich2) Call afficher_ligne(ligneAffich2) Range("A" & ligneAffich2).Select End If
If (plus = True And ligneAffich2 < fin And ligneAffich2 >= 3) Then ligneAffich2 = ligneAffich2 + 1 Call afficher_ligne(ligneAffich2) Range("A" & ligneAffich2).Select End If
If ((moins = False And plus = False) Or (ligneAffich2 < 3 Or ligneAffich2 > fin)) Then MsgBox ("sinon " & ligneAffich2) Call afficher_ligne(fin) Range("A" & fin).Select End If
moins = False plus = False end sub
je vous épargne la première partie de la méthode, qui fonctionnne, ainsi que la méthode affichage, qui ne fait que du remplissage de case.
Si quelqu'un pouvait éclairer ma lanterne ...
Merci
bonjour Julius,
je ne crois pas que ce soit une bonne idée de nommer un objet (bouton) et une variable (moins As Boolean) du même nom.
Private Sub CommandButton1_Click()
Call afficher_inter(1, 0)
End Sub
Private Sub CommandButton2_Click()
Call afficher_inter(0, 1)
End Sub
Private Sub afficher_inter(ByVal moins As Boolean, ByVal plus As Boolean)
On Error Resume Next
With UserForm1.ComboBox1
lgn = .ListIndex
If moins Then UserForm1.ComboBox1.ListIndex = UserForm1.ComboBox1.ListIndex - 1
If plus Then UserForm1.ComboBox1.ListIndex = UserForm1.ComboBox1.ListIndex + 1
End With
End Sub
isabelle
Bonjour et, bonne année tout le monde.
Mon problème d'aujourd'hui me laisse perplexe.
J'ai créé un userform pour afficher et faire défiler les données d'une table
(pour rendre la consulation plus lisible).
j'y ai rajouté 2 boutons : + et - .
et c'est là que je commence à ne plus comprendre .
Quand je clic sur "-" la première fois tout se passe bien, il m'affiche la
ligne précédente. Puis après, il compte de 2 en 2. Je rate donc une ligne sur
2.
Quand je clic sur "+" en revanche, il ne se passe strictement rien alors que
j'ai l'impression de faire le même appel.
voici mon code :
Private Sub moins_Click()
Call afficher_inter(rech_service.Value, rech_inter.Value, False, True)
End Sub
Private Sub plus_Click()
Call afficher_inter(rech_service.Value, rech_inter.Value, True, False)
End Sub
Private Sub afficher_inter(ByVal S_service As String, ByVal S_inter As
String, ByVal plus As Boolean, ByVal moins As Boolean)
...
'2ème partie : on affiche l'intervention correspondante la plus récente
Worksheets("Temp").Activate
fin = Application.Sheets("Temp").Range("A1").End(xlDown).Row
ligneAffich2 = ActiveCell.Rows
If (moins = True And ligneAffich2 > 3 And ligneAffich2 <= fin) Then
ligneAffich2 = ligneAffich2 - 1
'ligneAffich2 = ActiveCell.Rows - 1
'MsgBox ("moins " & ligneAffich2)
Call afficher_ligne(ligneAffich2)
Range("A" & ligneAffich2).Select
End If
If (plus = True And ligneAffich2 < fin And ligneAffich2 >= 3) Then
ligneAffich2 = ligneAffich2 + 1
Call afficher_ligne(ligneAffich2)
Range("A" & ligneAffich2).Select
End If
If ((moins = False And plus = False) Or (ligneAffich2 < 3 Or ligneAffich2 >
fin)) Then
MsgBox ("sinon " & ligneAffich2)
Call afficher_ligne(fin)
Range("A" & fin).Select
End If
moins = False
plus = False
end sub
je vous épargne la première partie de la méthode, qui fonctionnne, ainsi que
la méthode affichage, qui ne fait que du remplissage de case.
je ne crois pas que ce soit une bonne idée de nommer un objet (bouton) et une variable (moins As Boolean) du même nom.
Private Sub CommandButton1_Click() Call afficher_inter(1, 0) End Sub
Private Sub CommandButton2_Click() Call afficher_inter(0, 1) End Sub
Private Sub afficher_inter(ByVal moins As Boolean, ByVal plus As Boolean) On Error Resume Next With UserForm1.ComboBox1 lgn = .ListIndex If moins Then UserForm1.ComboBox1.ListIndex = UserForm1.ComboBox1.ListIndex - 1 If plus Then UserForm1.ComboBox1.ListIndex = UserForm1.ComboBox1.ListIndex + 1 End With End Sub
isabelle
Bonjour et, bonne année tout le monde.
Mon problème d'aujourd'hui me laisse perplexe. J'ai créé un userform pour afficher et faire défiler les données d'une table (pour rendre la consulation plus lisible). j'y ai rajouté 2 boutons : + et - . et c'est là que je commence à ne plus comprendre .
Quand je clic sur "-" la première fois tout se passe bien, il m'affiche la ligne précédente. Puis après, il compte de 2 en 2. Je rate donc une ligne sur 2. Quand je clic sur "+" en revanche, il ne se passe strictement rien alors que j'ai l'impression de faire le même appel.
voici mon code :
Private Sub moins_Click() Call afficher_inter(rech_service.Value, rech_inter.Value, False, True) End Sub
Private Sub plus_Click() Call afficher_inter(rech_service.Value, rech_inter.Value, True, False) End Sub
Private Sub afficher_inter(ByVal S_service As String, ByVal S_inter As String, ByVal plus As Boolean, ByVal moins As Boolean)
...
'2ème partie : on affiche l'intervention correspondante la plus récente Worksheets("Temp").Activate fin = Application.Sheets("Temp").Range("A1").End(xlDown).Row ligneAffich2 = ActiveCell.Rows
If (moins = True And ligneAffich2 > 3 And ligneAffich2 <= fin) Then ligneAffich2 = ligneAffich2 - 1 'ligneAffich2 = ActiveCell.Rows - 1 'MsgBox ("moins " & ligneAffich2) Call afficher_ligne(ligneAffich2) Range("A" & ligneAffich2).Select End If
If (plus = True And ligneAffich2 < fin And ligneAffich2 >= 3) Then ligneAffich2 = ligneAffich2 + 1 Call afficher_ligne(ligneAffich2) Range("A" & ligneAffich2).Select End If
If ((moins = False And plus = False) Or (ligneAffich2 < 3 Or ligneAffich2 > fin)) Then MsgBox ("sinon " & ligneAffich2) Call afficher_ligne(fin) Range("A" & fin).Select End If
moins = False plus = False end sub
je vous épargne la première partie de la méthode, qui fonctionnne, ainsi que la méthode affichage, qui ne fait que du remplissage de case.
Si quelqu'un pouvait éclairer ma lanterne ...
Merci
isabelle
si tu veut que la valeur de la source soit également sélectionné, modifie la macro comme ça.
Private Sub afficher_inter(ByVal moin As Boolean, ByVal plus As Boolean) On Error Resume Next With UserForm1.ComboBox1 lgn = .ListIndex If moin Then .ListIndex = .ListIndex - 1 Sheets("Feuil1").Range("A" & .ListIndex + 1).Activate Else .ListIndex = .ListIndex + 1 Sheets("Feuil1").Range("A" & .ListIndex + 1).Activate End If End With End Sub
isabelle
Bonjour et, bonne année tout le monde.
Mon problème d'aujourd'hui me laisse perplexe. J'ai créé un userform pour afficher et faire défiler les données d'une table (pour rendre la consulation plus lisible). j'y ai rajouté 2 boutons : + et - . et c'est là que je commence à ne plus comprendre .
Quand je clic sur "-" la première fois tout se passe bien, il m'affiche la ligne précédente. Puis après, il compte de 2 en 2. Je rate donc une ligne sur 2. Quand je clic sur "+" en revanche, il ne se passe strictement rien alors que j'ai l'impression de faire le même appel.
voici mon code :
Private Sub moins_Click() Call afficher_inter(rech_service.Value, rech_inter.Value, False, True) End Sub
Private Sub plus_Click() Call afficher_inter(rech_service.Value, rech_inter.Value, True, False) End Sub
Private Sub afficher_inter(ByVal S_service As String, ByVal S_inter As String, ByVal plus As Boolean, ByVal moins As Boolean)
...
'2ème partie : on affiche l'intervention correspondante la plus récente Worksheets("Temp").Activate fin = Application.Sheets("Temp").Range("A1").End(xlDown).Row ligneAffich2 = ActiveCell.Rows
If (moins = True And ligneAffich2 > 3 And ligneAffich2 <= fin) Then ligneAffich2 = ligneAffich2 - 1 'ligneAffich2 = ActiveCell.Rows - 1 'MsgBox ("moins " & ligneAffich2) Call afficher_ligne(ligneAffich2) Range("A" & ligneAffich2).Select End If
If (plus = True And ligneAffich2 < fin And ligneAffich2 >= 3) Then ligneAffich2 = ligneAffich2 + 1 Call afficher_ligne(ligneAffich2) Range("A" & ligneAffich2).Select End If
If ((moins = False And plus = False) Or (ligneAffich2 < 3 Or ligneAffich2 > fin)) Then MsgBox ("sinon " & ligneAffich2) Call afficher_ligne(fin) Range("A" & fin).Select End If
moins = False plus = False end sub
je vous épargne la première partie de la méthode, qui fonctionnne, ainsi que la méthode affichage, qui ne fait que du remplissage de case.
Si quelqu'un pouvait éclairer ma lanterne ...
Merci
si tu veut que la valeur de la source soit également sélectionné, modifie la macro comme ça.
Private Sub afficher_inter(ByVal moin As Boolean, ByVal plus As Boolean)
On Error Resume Next
With UserForm1.ComboBox1
lgn = .ListIndex
If moin Then
.ListIndex = .ListIndex - 1
Sheets("Feuil1").Range("A" & .ListIndex + 1).Activate
Else
.ListIndex = .ListIndex + 1
Sheets("Feuil1").Range("A" & .ListIndex + 1).Activate
End If
End With
End Sub
isabelle
Bonjour et, bonne année tout le monde.
Mon problème d'aujourd'hui me laisse perplexe.
J'ai créé un userform pour afficher et faire défiler les données d'une table
(pour rendre la consulation plus lisible).
j'y ai rajouté 2 boutons : + et - .
et c'est là que je commence à ne plus comprendre .
Quand je clic sur "-" la première fois tout se passe bien, il m'affiche la
ligne précédente. Puis après, il compte de 2 en 2. Je rate donc une ligne sur
2.
Quand je clic sur "+" en revanche, il ne se passe strictement rien alors que
j'ai l'impression de faire le même appel.
voici mon code :
Private Sub moins_Click()
Call afficher_inter(rech_service.Value, rech_inter.Value, False, True)
End Sub
Private Sub plus_Click()
Call afficher_inter(rech_service.Value, rech_inter.Value, True, False)
End Sub
Private Sub afficher_inter(ByVal S_service As String, ByVal S_inter As
String, ByVal plus As Boolean, ByVal moins As Boolean)
...
'2ème partie : on affiche l'intervention correspondante la plus récente
Worksheets("Temp").Activate
fin = Application.Sheets("Temp").Range("A1").End(xlDown).Row
ligneAffich2 = ActiveCell.Rows
If (moins = True And ligneAffich2 > 3 And ligneAffich2 <= fin) Then
ligneAffich2 = ligneAffich2 - 1
'ligneAffich2 = ActiveCell.Rows - 1
'MsgBox ("moins " & ligneAffich2)
Call afficher_ligne(ligneAffich2)
Range("A" & ligneAffich2).Select
End If
If (plus = True And ligneAffich2 < fin And ligneAffich2 >= 3) Then
ligneAffich2 = ligneAffich2 + 1
Call afficher_ligne(ligneAffich2)
Range("A" & ligneAffich2).Select
End If
If ((moins = False And plus = False) Or (ligneAffich2 < 3 Or ligneAffich2 >
fin)) Then
MsgBox ("sinon " & ligneAffich2)
Call afficher_ligne(fin)
Range("A" & fin).Select
End If
moins = False
plus = False
end sub
je vous épargne la première partie de la méthode, qui fonctionnne, ainsi que
la méthode affichage, qui ne fait que du remplissage de case.
si tu veut que la valeur de la source soit également sélectionné, modifie la macro comme ça.
Private Sub afficher_inter(ByVal moin As Boolean, ByVal plus As Boolean) On Error Resume Next With UserForm1.ComboBox1 lgn = .ListIndex If moin Then .ListIndex = .ListIndex - 1 Sheets("Feuil1").Range("A" & .ListIndex + 1).Activate Else .ListIndex = .ListIndex + 1 Sheets("Feuil1").Range("A" & .ListIndex + 1).Activate End If End With End Sub
isabelle
Bonjour et, bonne année tout le monde.
Mon problème d'aujourd'hui me laisse perplexe. J'ai créé un userform pour afficher et faire défiler les données d'une table (pour rendre la consulation plus lisible). j'y ai rajouté 2 boutons : + et - . et c'est là que je commence à ne plus comprendre .
Quand je clic sur "-" la première fois tout se passe bien, il m'affiche la ligne précédente. Puis après, il compte de 2 en 2. Je rate donc une ligne sur 2. Quand je clic sur "+" en revanche, il ne se passe strictement rien alors que j'ai l'impression de faire le même appel.
voici mon code :
Private Sub moins_Click() Call afficher_inter(rech_service.Value, rech_inter.Value, False, True) End Sub
Private Sub plus_Click() Call afficher_inter(rech_service.Value, rech_inter.Value, True, False) End Sub
Private Sub afficher_inter(ByVal S_service As String, ByVal S_inter As String, ByVal plus As Boolean, ByVal moins As Boolean)
...
'2ème partie : on affiche l'intervention correspondante la plus récente Worksheets("Temp").Activate fin = Application.Sheets("Temp").Range("A1").End(xlDown).Row ligneAffich2 = ActiveCell.Rows
If (moins = True And ligneAffich2 > 3 And ligneAffich2 <= fin) Then ligneAffich2 = ligneAffich2 - 1 'ligneAffich2 = ActiveCell.Rows - 1 'MsgBox ("moins " & ligneAffich2) Call afficher_ligne(ligneAffich2) Range("A" & ligneAffich2).Select End If
If (plus = True And ligneAffich2 < fin And ligneAffich2 >= 3) Then ligneAffich2 = ligneAffich2 + 1 Call afficher_ligne(ligneAffich2) Range("A" & ligneAffich2).Select End If
If ((moins = False And plus = False) Or (ligneAffich2 < 3 Or ligneAffich2 > fin)) Then MsgBox ("sinon " & ligneAffich2) Call afficher_ligne(fin) Range("A" & fin).Select End If
moins = False plus = False end sub
je vous épargne la première partie de la méthode, qui fonctionnne, ainsi que la méthode affichage, qui ne fait que du remplissage de case.