0

我有一个用户表单,允许用户在三个文本框中输入信息以进行登录删除。该数据输入到它后面的 excel 表中。我想这样做,所以在用户将数据输入第一个框后,它将创建另外 3 个框。这种模式会重复。

第一个框分配给“删除登录!A2”

目前,我一直在尝试这样做,但无济于事。

Private Sub Worksheet_Change(ByVal Target As Range)
Select Case Left(Target.Address, 2)
    Case Is = "$A"
        Dim cCntrl As Control
        Dim i As Integer

        For i = 0 To 2
            Set cCntrl = UserForm1.Frame10.Controls.Add("Forms.TextBox.1", "Login" & i & Target.Row + 1, True)
            With cCntrl
                .Width = UserForm1.TextBox240.Width
                .Height = UserForm1.TextBox240.Height
                .Top = (10 + UserForm1.TextBox240.Height) * (Target.Row - 3)
                .Left = UserForm1.TextBox154.Left + (UserForm1.TextBox154.Width) * i
                .ControlSource = "'Delete Logins'!" & Chr(65 + i) & Target.Row + 1
            End With
         Next
End Select
End Sub

前三个框已正确分配,但不会创建新的文本框。

4

1 回答 1

0

正在创建文本框,但我没有正确放置它们。它们基本上是一个接一个地堆叠在一起。

Private Sub Worksheet_Change(ByVal Target As Range)
Select Case Left(Target.Address, 2)
    Case Is = "$A"
    'If Target.Value <> "" Then
        'If UserForm1 <> Nothing Then
        Dim cCntrl As Control
        Dim i As Integer

        For i = 0 To 2
            Set cCntrl = UserForm1.Frame10.Controls.Add("Forms.TextBox.1", "Login" & i & Target.Row + 1, True)
            With cCntrl
                .Width = UserForm1.TextBox240.Width
                .Height = UserForm1.TextBox240.Height
                .Top = (10 + UserForm1.TextBox240.Height) * (Target.Row - 1)
                .Left = UserForm1.TextBox240.Left + (UserForm1.TextBox240.Width) * i
                .ControlSource = "'Delete Logins'!" & Chr(65 + i) & Target.Row + 1
            End With
         Next
   ' End If
End Select
End Sub
于 2013-11-11T19:15:25.747 回答