タイトルは問題の概要を示しているはずですが、ユーザーフォームのコンボボックスで使用する動的な名前付き範囲を実行しています。フォームを実行すると、値が意図したとおりに表示されます。コマンド ボタンからモジュール サブルーチンを呼び出すと、値が表示されず、その理由がわかりません。
すべてのコードを貼り付けて、以下の問題のあるスニペットを強調表示します。
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
非常に多くのコードを投稿して申し訳ありませんが、何が問題を引き起こしているのか正確にはわかりません。私はまだフォームの新人です。
どんな助けでも大歓迎です。ありがとう。