2012-06-26 3 views
0

엑셀 2007 워크 시트에서 액티브 X와 폼 컨트롤 (테스트 목적의 드롭 다운)이 있습니다. 나는 아래의 코드를 사용하여 데이터를 바인더 제본 한 :액티브 X 컨트롤과 엑셀의 폼 컨트롤

Private Sub ComboBox1_Change() 
    If ComboBox1.Value = 1 Then 
     ComboBox2.List = Array("a", "b", "c") 
     ComboBox2.Value = ComboBox2.List(0) 
    ElseIf ComboBox1.Value = 2 Then 
     ComboBox2.List = Array("A", "B", "C", "D") 
     ComboBox2.Value = ComboBox2.List(0)   
    End If 
End Sub 

Private Sub Worksheet_Activate() 
    ComboBox1.List = Array(1, 2) 
    ComboBox3.List = Array("Delhi", "Kolkata") 
    ComboBox3.Value = ComboBox3.List(0) 
    ComboBox4.List = Array("Delhi6", "Kolkata71") 
    ComboBox4.Value = ComboBox4.List(0) 
End Sub 

Private Sub UserForm_Initialize() 
    ComboBox1.List = Array(1, 2) 
End Sub 

을하지만 내 워크 시트를 다시 열 때 콤보은 폐쇄 했다있는 상태에서 개방되고 데이터가 드롭 다운에 남아 없습니다. 어떤 이벤트를 놓치면 알려주시겠습니까 ?? 내가 만들고 있었다 실수 ... 내 시트에 사용 된 UserForm_Initialize 기능 (내 친구의 도움을 복용) 발견

+0

1) 컨트롤이 워크 시트에있는 경우 왜 'UserForm_Initialize'를 사용합니까? 2) 컨트롤은 첫 번째 시트에 있습니까? 3) 콤보 박스는 ActiveX 컨트롤인가 컨트롤인가? –

+0

안녕하세요, 컨트롤은 sheet1에 있습니다. ComboBox1과 2는 폼 컨트롤이며 3,4는 activex입니다. – Premanshu

+0

Q2와 Q3에 답해 주셔서 감사합니다. Q1과 함께 남았습니다. :) –

답변

0

사전에

덕분에 ... 전혀 사용하지 않아야합니다. 두 번째로 Worksheet_Activate도 사용되지 않습니다.

필요한 functon는 Microsoft Excel에서 개체 아래에서 ThisWorkbook에 사용되는

Private Sub Workbook_Open() 
Sheets("Print_Sheet").ComboBox1.List = Array(1, 2, 3, 4) 
Sheets("Print_Sheet").ComboBox3.List = Array("Delhi", "Kolkata") 
Sheets("Print_Sheet").ComboBox3.Value = ComboBox3.List(0) 
Sheets("Print_Sheet").ComboBox4.List = Array("Delhi6", "Kolkata71") 
Sheets("Print_Sheet").ComboBox4.Value = ComboBox4.List(0) 
End Sub 

입니다. 이제 콤보가 올바르게 채워집니다.