Vba 验证列表-不能引用“公式1”中另一张表中的范围作为变量

Vba 验证列表-不能引用“公式1”中另一张表中的范围作为变量,vba,excel,Vba,Excel,所有变量都相应声明,验证列表代码中的公式1部分是否存在引用问题 ,验证列表代码中的公式1部分是否存在引用问题 是:选择是一个对象。明确使用.Address属性: Set AcctRng = Sheets("New Accounts").Range(Cells(2, 1),Cells(countnonblank1 + 1, 1)) CntNBlnk = Application.WorksheetFunction.CountA(AcctRng) Set MasterSht = T

所有变量都相应声明,验证列表代码中的公式1部分是否存在引用问题

,验证列表代码中的公式1部分是否存在引用问题

是:选择是一个对象。明确使用.Address属性:

   Set AcctRng = Sheets("New Accounts").Range(Cells(2, 1),Cells(countnonblank1 + 1, 1))
   CntNBlnk = Application.WorksheetFunction.CountA(AcctRng)

   Set MasterSht = ThisWorkbook.Worksheets("Master Data")
   LstRo = MasterSht.Cells(MasterSht.Rows.Count, "A").End(xlUp).Row

 '  Sheets("New Accounts").Range("a5") = LstRo

   Set ChoiceRng = Sheets("Master Data").Range(Cells(4, 1), Cells(LstRo, 1))
   'Sheets("Master Data").Range(Cells(4, 1), Cells(LstRo, 1))


 '  Choice = "ChoiceRange"


     Sheets("New Accounts").Range(Cells(2, 2), Cells(CntNBlnk + 1, 2)).Select
     With Selection.Validation
    .Delete
   .Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:= _
     xlBetween, Formula1:=ChoiceRng
    .IgnoreBlank = True
    .InCellDropdown = True
    .InputTitle = ""
    .ErrorTitle = ""
    .InputMessage = ""
    .ErrorMessage = ""
    .ShowInput = True
    .ShowError = True
End With

Excel的哪个版本?版本是Excel 2010
.Add Type:=xlValidateList, _
     AlertStyle:=xlValidAlertStop,  _
     Operator:=xlBetween, _
     Formula1:=ChoiceRng.Address