稱爲標題應該給這個問題一個公平的概述,但。當我運行表單時,這些值按預期顯示。當我通過命令按鈕調用模塊子例程時,值不會出現,我不知道爲什麼。Excel的VBA:動態範圍ComboBox.Rowsource值我正在爲一個窗體在組合框中使用動態範圍命名時不顯示用戶窗體命令按鈕
我會粘貼所有的代碼,並突出以下違規片段(S):
Private Sub btnGetGAToken_Click()
'--------------------------------
'Obtain API Token from Google Analytics (GA), indicate to user that token has been obtained and populate Account combobox
'with a unique list of accounts, which will in turn populate the Profile combobox with the profiles associated with the chosen
'account
'--------------------------------
Dim txtEmailField As String
Dim txtPasswordField As String
'Values written to sheet for use in UDFToken and UDFGetGAAcctData array formulas
Range("FieldEmail").Value = Me.txtEmailField.Text
Range("FieldPassword").Value = Me.txtPasswordField.Text
Range("GAToken").Calculate
With Me.lblGATokenResponseField
.Caption = Range("GAToken").Value
.ForeColor = RGB(2, 80, 0)
End With
Call FindUniqueAccountNames
cboAccountNamesComboBox.RowSource = Sheet1.Range("ListUniqueAccountNames").Address
End Sub
Private Sub cboAccountNamesComboBox_Change()
'Value written to sheet for use in the 'ListProfileNames' dynamic, named range
Range("ChosenAccount").Value = Me.cboAccountNamesComboBox.Value
With Me.cboProfileNamesComboBox
.Value = ""
.RowSource = Sheets("CodeMetaData").Range("ListProfileNames").Address
End With
End Sub
動態範圍使用名稱管理器創建和低於:
命名範圍:「ListUniqueAccountNames」 = OFFSET(!CodeMetaData附加$ J $ 5,0,0,COUNTA(CodeMetaData附加$ J $ 5:!附加$ J $ 5000))
和便於參考,我使用的運行它的代碼如下:
cboAccountNamesComboBox.RowSource = Sheets("CodeMetaData").Range("ListUniqueAccountNames").Address
的子程序調用用戶窗體是在這裏:
Public Sub ShowReportSpecsForm()
Load frmReportSpecs
frmReportSpecs.Show
End Sub
原諒我張貼了這麼多的代碼,但我不知道它到底是什麼是造成這個問題 - 我仍然非常有形式的新手。
任何幫助將不勝感激。謝謝。
調試時,你是否檢查'Sheets(「CodeMetaData」)。Range(「ListUniqueAccountNames」)。Address' values? – JMax