簡體   English   中英

對象_worksheet的方法范圍失敗

[英]method range of object _worksheet failed

我有一個要嘗試繪制到范圍內的公式-通過Print.Debug,我可以看到我的公式很有意義,但是Range不能計算,但會引發標題錯誤。

在Print.Debug中,我可以看到str是=

=OFFSET(Menu!A:A,(3+COUNTIF(Menu!F:F,"Drikke")+COUNTIF(Menu!F:F,"Ernæring")-1),0,COUNTIF(Menu!F:F,"Mad"),1)

我的代碼行如下所示:

With cboTemp
  'show the combobox with the list
  .Visible = True
  .Left = Target.Left
  .Top = Target.Top
  .Width = Target.Width + 5
  .Height = Target.Height + 5
  Problem is, that I'm taking the formula from a datavalidated, and it's not parsing correctly. I'm using: .ListFillRange = Target.Validation.Formula1 , but the range of the datavalidation is not shown, and I know from the original cell, that the formula is valid <---- Line that throws error
  .LinkedCell = Target.Address
End With

為什么會引發錯誤?

編輯

我嘗試使用以下方法從經過數據驗證的單元格中獲取公式(str):. .ListFillRange = Target.Validation.Formula1 ,但是未顯示datavalidation的范圍,而且我從原始單元格中知道該公式有效

我現在沒有收到錯誤,但是也沒有顯示范圍-我懷疑這與“ IgnoreBlankCells”屬性有關嗎?

與其給它一個Range對象,不如給它您的str對象。

嘗試

.ListFillRange = str

這是關於動態設置此主題一個好問題

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM