incrémenter...

tom59

XLDnaute Nouveau
Bonjour @ tous
Je voudrais créer un UserForm qui affiche simplement le contenu de la cellule B8 puis, lorsque je clique sur un bouton, il m'affiche les informations de la cellule B9, B10...
J'ai écrit ça pour l'instant mais ça ne fonctionne pas. Je dois avouer ne pas etre très calé sur VB...

Private Sub UserForm_Initialize()
Dim cpt As Integer
cpt = 8
Label1 = Sheets('feuil2').Range('B' & cpt).Value
CommandButton1.Caption = 'VRAI'
CommandButton2.Caption = 'FAUX'
End Sub

Private Sub CommandButton1_Click()
cpt = cpt + 1
Label1 = Sheets('feuil2').Range('B' & cpt).Value
End Sub

Il ne me donne aucune erreur mais ne m'affiche rien non plus...
Toute aide sera la bienvenue...

Message édité par: tom59, à: 19/01/2006 23:48
 

Charly2

Nous a quittés en 2006
Repose en paix
Bonsoir tom59 :)

Une solution dans le fichier joint. Le code dans l'USF :

Option Explicit

Dim Cpt As Long

Private Sub UserForm_Initialize()
'
  Cpt = 8
  With Me
    .Label1 = Sheets('Feuil2').Range('B' & Cpt).Value
    .CommandButton1.Caption = 'Suivant'
    .CommandButton2.Caption = 'Sortir'
  End With
End Sub

Private Sub CommandButton1_Click()
'
' Bouton Suivant
'

  If Cpt < Sheets('Feuil2').Range('B65536').End(xlUp).Row Then
    Cpt = Cpt + 1
  Else
    Cpt = 8
  End If
  Me.Label1 = Sheets('Feuil2').Range('B' & Cpt).Value
End Sub

Private Sub CommandButton2_Click()
'
' Bouton Sortir
'

  Me.Hide
End Sub
[file name=tom59.zip size=11259]http://www.excel-downloads.com/components/com_simpleboard/uploaded/files/tom59.zip[/file]

A+ ;)
 

Pièces jointes

  • tom59.zip
    11 KB · Affichages: 15

Discussions similaires

Réponses
7
Affichages
1 K
Réponses
3
Affichages
322

Statistiques des forums

Discussions
312 225
Messages
2 086 411
Membres
103 201
dernier inscrit
centrale vet