返回列表 上一主題 發帖

求 開啟表單自動新增文字方塊 與下拉式清單

回復 1# joe80502
  1. Private Sub UserForm_Initialize()
  2. With ActiveSheet
  3. For Each a In .Range("A:A").SpecialCells(xlCellTypeConstants)
  4.    With Me.Controls.Add("Forms.TextBox.1")
  5.    .Top = i * 22
  6.    .Height = 20
  7.    .Width = 60
  8.    .Left = 10
  9.    .Value = a
  10.    End With
  11.    With Me.Controls.Add("Forms.ComboBox.1")
  12.    .Top = i * 22
  13.    .Height = 20
  14.    .Width = 60
  15.    .Left = 50
  16.    End With
  17.    i = i + 1
  18. Next
  19. End With
  20. End Sub
複製代碼
學海無涯_不恥下問

TOP

回復 4# joe80502
回填資料到工作表中,可利用ControlSource屬性
  1. Private Sub UserForm_Initialize()
  2. With ActiveSheet
  3. For Each a In .Range("A:A").SpecialCells(xlCellTypeConstants)
  4.    With Me.Controls.Add("Forms.TextBox.1")
  5.    .Top = i * 22
  6.    .Height = 20
  7.    .Width = 60
  8.    .Left = 10
  9.    .Value = a
  10.    End With
  11.    With Me.Controls.Add("Forms.ComboBox.1")
  12.    .Top = i * 22
  13.    .Height = 20
  14.    .Width = 60
  15.    .Left = 50
  16.    .ControlSource = a.Offset(, 5).Address '連結儲存格
  17.    .RowSource = 工作表1.[A1:A7].Address '清單來源
  18.    End With
  19.    i = i + 1
  20. Next
  21. End With
  22. End Sub
複製代碼
學海無涯_不恥下問

TOP

        靜思自在 : 天上最美是星星,人生最美是溫情。
返回列表 上一主題