Bonjour,
Etant un débutant, je suis un peu perdu dans mon code.
J'ai un code qui numérote dans un sens ou dans l'autre et qui fonctionne bien.
L'emplacement des n° était défini dans le UserForm1, donc quasiment fixe.
Mais je voudrai définir l'emplacement des n° en mettant n1 et n2 dans les cellules qui doivent recevoir les numéros.
J'ai bidouillé quelques lignes mais cela ne fonctionne pas et je ne sais pas vraiment quelle fonction utilisée.
Si quelqu'un pouvait m'aider, se serait sympa.
Je joins mon code.
Merci, Chgo
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
Private Sub CommandButton1_Click()
    Dim PageDe As Single, PageA As Single, p As Single
    Dim sPas As Single, sBorneMin As Single, sBorneMax As Single
    Dim celA As String, celB As String, celC As String, celD As String
 
    Dim i As String
      For i = 1 To 2
        If Range("A1:T21").Value = Cells.Value = "n1""n2" Then
 
        If TextBox1.Value <> "" And TextBox2.Value <> "" Then
          PageDe = TextBox2
          PageA = TextBox1 / 5
 
        Unload Me
 
        If CheckBox1.Value = True Then
            sBorneMin = PageDe
            sBorneMax = PageA + TextBox2 - 1
            sPas = 1
        Else
            sBorneMin = PageA + TextBox2 - 1
            sBorneMax = PageDe
            sPas = -1
        End If
 
        For p = sBorneMin To sBorneMax Step sPas
            Range("D13", Cells.Value = n1).Value = p
            Range(Cells.Value = n2).Value = p + 1 * PageA
            Worksheets("Feuil4").PrintOut
 
        Next p
 
        Range("D13").Value = 0
       End If
 
    End If
 
  Next i
 
 
 
End Sub
 
Private Sub CommandButton2_Click()
    Unload Me
End Sub
 
 
Private Sub TextBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean)
    If TextBox1.Value <> vbNullString Then
        If CLng(TextBox1.Value) Mod 5 <> 0 Then
            MsgBox "Veuillez saisir un multiple de 5", vbCritical + vbOKOnly, "Attention..."
            Cancel = True
            TextBox1.Value = ""
            TextBox1.SetFocus
        End If
    End If
End Sub
 
Private Sub TextBox1_Change()
    Label4.Caption = 0
    If TextBox1.Value <> "" Then Label4.Caption = Label4.Caption + CLng(TextBox1.Value)
    If TextBox2.Value <> "" Then Label4.Caption = Label4.Caption + CLng(TextBox2.Value)
    Label6.Caption = 0
    If TextBox1.Value <> "" Then Label6.Caption = CDbl(TextBox1 / 5)
End Sub
 
Private Sub TextBox2_Change()
    Label4.Caption = -1
    If TextBox1.Value <> "" Then Label4.Caption = Label4.Caption + CLng(TextBox1.Value)
    If TextBox2.Value <> "" Then Label4.Caption = Label4.Caption + CLng(TextBox2.Value)
End Sub