2012-11-01 5 views
0

다른 워크 시트의 레이블 배열 (범위)이있는 콤보 상자를로드하려고합니다. 셀 메서드 대신 범위에서 "A4 : PB4"를 사용하면 작동합니다. 이것이 작동하지 않는 이유를 모릅니다. 내가 제대로 범위 내에서 세포를 사용하여다른 워크 시트의 범위

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 
+0

건가요? –

답변

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 
관련 문제