콤보 상자로 문제를 해결하려고합니다. 나열된 옵션을 사용하면 매크로가 실행될 때마다 다른 double을 생성하지 않아도됩니다. AddItem 속성은 콤보 상자를 채우는 데만 사용됩니다. 이 프로젝트는 사용자가 해당 표를 인쇄 미리보기 모드로 표시 할 수 있도록 사용자 양식 내의 드롭 다운 메뉴에 12 개월을 나열하는 것입니다 (수반되는 워크 시트에는 매월 표가 있음). 그 달 동안 문자열 배열을 작성한 다음 콤보 상자에 루프의 AddItem 속성을 채우라고했습니다. 재치에 :콤보 상자에 사용자 서식의 문자열 배열 채우기
Private Sub ComboBox1_Change()
Dim strMonth(0 To 11) As String
strMonth(0) = "Print April Table"
strMonth(1) = "Print May Table"
strMonth(2) = "Print June Table"
strMonth(3) = "Print July Table"
strMonth(4) = "Print August Table"
strMonth(5) = "Print September Table"
strMonth(6) = "Print October Table"
strMonth(7) = "Print November Table"
strMonth(8) = "Print December Table"
strMonth(9) = "Print January Table"
strMonth(10) = "Print February Table"
strMonth(11) = "Print March Table"
Dim mthPosition As Long
For mthPosition = LBound(strMonth) To UBound(strMonth)
UserForm13.ComboBox1.AddItem strMonth(mthPosition)
Next mthPosition
With UserForm13.ComboBox1
.Style = fmStyleDropDownList
End With
UserForm13.Show
End Sub
어떤 이유로, 나는 코드가 실행되는 경우 경로가 지정된 경우에도 ... 같은 일이 발생, VBA가 지정한 개체를 찾을 수 없다고 말하는 AddItem을 줄에서 오류가 발생 ComboBox에 대한 루틴 아래에서 실행되거나 별도의 루틴에서 테스트됩니다.
감사합니다.
이 코드는 다른 사용자 폼에 있습니까? –
다른 폼이 실제로 'UserForm13'으로 지정되어 있고 그 콤보 상자가 실제로'ComboBox1'라고되어 있습니까? –
Robin, 실제로 - 물건의 이름을 확인했는데 아무 것도 없었습니다. 찾을 수있는 문제. – quadrature