none
VBA Data Type RRS feed

  • Question

  • With the following code:

    dim rng As Range

    dim arr(1 to 1)

    Set rng = ThisWorkbook.Worksheets(1).Range("A1:E5")

    arr(1,1) = rng

    MsgBox Typename(arr(1,1))

    The Message Box displays Variant() instead of Range.

    What's up with that?

    Thanks.

    Monday, November 20, 2017 11:09 PM

All replies

  • Oops. The fourth line of the code should be

    arr(1) = rng

    and the fifth

    MsgBox Typename(arr(1))

    Monday, November 20, 2017 11:29 PM
  • Set arr(1) = rng

    Tuesday, November 21, 2017 2:59 AM
  • I agree Alan Beban and James Cone.
     Dim rng As Range
     Dim arr(1 To 1) As Range
     Set rng = ThisWorkbook.Worksheets(1).Range("A1:E5")
     Set arr(1) = rng
     MsgBox TypeName(arr(1))

    Ashidacchi

    Wednesday, November 22, 2017 3:15 AM
  • Hi Alan,

    Has your original issue been resolved? If it has, I would suggest you mark the helpful reply as answer or provide your solution and mark as answer to close this thread. If not, please feel free to let us know your current issue.

    Best Regards,

    Terry


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Thursday, November 23, 2017 6:02 AM