VBA组合盒不要"介意"我的动态范围选择

时间:2014-11-03 17:47:28

标签: excel vba excel-vba dynamic

我已经定义了一个包含组合框列表的数据库。在每列上,我有各种选项来分别填充组合框。当我运行我的userform时,前两个组合框(客户端和产品)显示选项就好了。为什么其他组合框都列出了客户端选项?

Private Sub UserForm_Initialize()
Dim cClient As Range
Dim cProduct As Range
Dim cSize As Range
Dim cType As Range
Dim cTax As Range

Dim ws As Worksheet
Set ws = Worksheets("aux")

For Each cClient In ws.Range("ClientList")
  With Me.comboClient
    .AddItem cClient.Value
  End With
Next cClient

For Each cProduct In ws.Range("ProductList")
  With Me.comboProduct
    .AddItem cProduct.Value
  End With
Next cProduct

For Each cSize In ws.Range("ClientList")
  With Me.comboSize
    .AddItem cSize.Value
  End With
Next cSize

For Each cType In ws.Range("ClientList")
  With Me.comboType
  .AddItem cType.Value
  End With
Next cType

For Each cTax In ws.Range("ClientList")
  With Me.comboTax
    .AddItem cTax.Value
  End With
Next cTax

Me.textDate.Value = Format(Date, "Medium Date")
Me.textDate.SetFocus

End Sub

1 个答案:

答案 0 :(得分:0)

似乎您使用ClientList范围中的值填充这些组合框。尝试从工作表上的其他范围中获取值(例如For Each cSize In ws.Range ("SizeList")