Skip to Content

VBA to refer to a Crosstab

Hi

I'm looking to refer to a crosstable as a ListObject within VBA, however I cannot figure it out how to.

Power Query does recognize BEx crosstables as table, therefore I was thinking I could do the same with VBA.

I'm trying to do the following, however it runs into an error, saying subscript out of range, meaning it cannot be found. Any ideas?

dim tbl as ListObject

set tbl = mysheet.ListObject("SAPCrosstable1")

Thanks!

Add a comment
10|10000 characters needed characters exceeded

Related questions

1 Answer

  • Best Answer
    Posted on May 19 at 10:03 PM

    Try this

    Dim DirArray As Variant
    DirArray = mysheet.Range("SAPCrosstable1").Value
    Add a comment
    10|10000 characters needed characters exceeded

    • Thanks Alen!

      The reason I was looking to do this, because I wanted to copy the dataset (without headers) from the Crosstable(s) without having to check the last row / last column. I guess it would be still faster to copy/paste the dataset with the Range.Copy / PasteSpecial method, rather than looping through the whole array.

      Regardless I've learned something new!

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.