如何将范围对象传递给VBA中的属性?

时间:2018-04-07 08:12:28

标签: excel-vba userform vba excel

虽然搜索得很彻底,但我没有通过属性将范围传递给userform。我得到了所需的错误对象。代码在userform内,参数prange是全局的。任何帮助将不胜感激。感谢。

Public Property Get MyRng() As Range

Set MyRng = r1

End Property

Public Property Set MyRng(ByRef prange As Range)

Set r1 = prange

End Property

1 个答案:

答案 0 :(得分:2)

那应该是userform

中的代码
SELECT ?movementName ?famousName ?peopleName ?influenceName
        WHERE {
        ?m dc:subject <http://dbpedia.org/resource/Category:Art_movements> .
        ?m rdfs:label ?movementName .
        FILTER(LANG(?movementName) = "en")
        ?m dbp:knownFor ?a .
        ?a rdfs:label ?famousName .
        FILTER(LANG(?famousName) = "en")
        ?m dbp:movement ?b .
        ?b rdfs:label ?peopleName .
        FILTER(LANG(?peopleName) = "en")
        ?m dbp:influencedBy ?d .
        ?d rdfs:label ?influenceName .
        FILTER(LANG(?influenceName) = "en")
        }'

只是一个简单的例子

Option Explicit
Dim mRng As Range
Public Property Get myRng() As Range
    Set myRng = mRng
End Property

Public Property Set myRng(nRg As Range)
    Set mRng = nRg
End Property