0

我正在尝试从另一个工作表加载一个带有标签数组(范围)的组合框。如果我在范围内使用“A4:PB4”而不是 Cells 方法,它会起作用。不知道为什么这不起作用。

Private Sub ComboBox1_GotFocus()

 Dim myArray As Variant
 lastcol = Worksheets("data").Range("A4").End(xlToRight).Column
 myArray = WorksheetFunction.Transpose(Worksheets("data").Range(Cells(4, 1), Cells(4, lastcol)))
 With Me.ComboBox1
  .List = myArray
 End With

End Sub
4

1 回答 1

0
 Private Sub ComboBox1_GotFocus()

  Dim myArray As Variant

  lastcol = Worksheets("data").Range("A4").End(xlToRight).Column
  With Worksheets("data")
   Set SourceRng = .Range(.Cells(4, 1), .Cells(4, lastcol))
  End With
  myArray = WorksheetFunction.Transpose(SourceRng)
  With Me.ComboBox1
   .List = myArray
  End With

 End Sub
于 2012-11-03T13:21:32.280 回答