| 12
 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
 
 |  Private Sub UserForm_Activate()
With UserForm2.Controls.Add("Forms.Label.1", "Label1", True)
    .Caption = "Entrer les mots :"
    .Top = 5
    .Left = 10
    .Width = 100
    .Height = 15
End With
 
With UserForm2.Controls.Add("Forms.Label.1", "Label2", True)
    .Caption = "Feuille où copier :"
    .Top = UserForm2.Height - 90
    .Left = 10
    .Width = 100
    .Height = 15
End With
 
With UserForm2.Controls.Add("Forms.textbox.1", "TextboxFeuille", True)
    .Top = UserForm2.Height - 75
    .Left = 10
    .Width = 100
    .Height = 15
End With
 
Dim obj As Control
Set obj = UserForm2.Controls.Add("Forms.CommandButton.1", "CommandButton1", True)
With obj
    .Top = UserForm2.Height - 50
    .Width = 50
    .Left = (UserForm2.Width / 2) - (.Width / 2)
    .Height = 25
    .Caption = "Chercher"
End With
 
MsgBox UserForm2.Controls("TextboxFeuille").Name
With UserForm2.CodeModule
    j = .CountOfLines
    .InsertLines j + 1, "Sub " & CommandButton1 & "_Click()"
    .InsertLines j + 2, "call (Button_chercher)"
    .InsertLines j + 3, "End Sub"
End With
 
 
End Sub
Private Sub UserForm_AddControl(ByVal Control As MSForms.Control)
MsgBox TypeName(Control) & ": " & Control.Name
End Sub
Private Sub Button_chercher()
 
Dim i As Integer
Dim j As Integer
Dim k As Integer
 
For i = UserForm1.TextBox2 To UserForm1.TextBox3
    For j = UserForm1.TextBox4 To UserForm1.TextBox5
        For k = 1 To UserForm1.TextBox1
            If Cells(i, j) = UserForm2.Controls("Textbox" & k).Caption Then
                Cells(i, j).EntireRow.Select
                            Selection.Copy
                            Sheets(UserForm2.Controls("TextboxFeuille").Caption).Activate
                            Cells(cpt + 1, 1).Activate
                            ActiveSheet.Paste
                            cpt = cpt + 1
            End If
        Next
    Next
Next
End Sub | 
Partager