Boucle continue

roross

XLDnaute Junior
Bonjour;


Comment relier "trouvecellule" avec "CommandButton5_Click" exemple suivant :

Dim lign As Byte, col As Byte, y As Byte
*********************************
Private Sub CommandButton5_Click()
Dim x As Byte
If Not IsNumeric(TextBox1) Or TextBox1 = "" Then Exit Sub
If y + Val(TextBox1) > 152 Then 'on ne peut pas créer plus de 152 étiquettes
x = 152 - y
MsgBox "On ne peut créer que " & x & " étiquettes !"
Else
x = Val(TextBox1)
End If
With Feuil2
For i = 1 To x
If lign <= 38 Then
CreerEtiquettes lign, col
Else
lign = 2
col = col + 3
CreerEtiquettes lign, col
End If
lign = lign + 2
y = y + 1
Next
End With
CB1.ListIndex = -1
End Sub
*********************************
Private Sub trouvecellule()
Dim TV() As Variant, Trouvé As Boolean, L As Long, C As Long
TV = Range("A1:W39").Value
For C = 1 To 22 Step 3
For L = 2 To 38 Step 2
Trouvé = TV(L, C) = ""
If Trouvé Then Exit For
Next L
If Trouvé Then Exit For
Next C
If Trouvé Then
CB2 = Cells(L, C).Address(False, False)
Else
MsgBox "Aucun emplacement libre"
End If
End Sub
*********************************
Private Sub CB2_Change()
If CB2 = "A2" Then
Range("A2").Select
ElseIf CB2 = "A4" Then
Range("A4").Select
-
-
-
-
ElseIf CB2 = "V38" Then
Range("V38").Select
End If
End Sub
*********************************
Private Sub UserForm_Initialize()
trouvecellule
With Worksheets("Feuil")
CB1.List = .Range("A3:A" & .Range("A65536").End(xlUp).Row).Value
End With
'EffaceEtiquettes
lign = 2
col = 1
End Sub
*********************************
Sub CreerEtiquettes(a As Byte, b As Byte)
With Feuil2
.Cells(a, b) = TextBox2
.Cells(a, b + 1) = TextBox3
.Cells(a + 1, b) = Format(TextBox4, "#,##0.00")
End With
End Sub
 
Dernière édition:

Discussions similaires

Réponses
2
Affichages
153

Statistiques des forums

Discussions
312 229
Messages
2 086 426
Membres
103 206
dernier inscrit
diambote