Get table range in VBA (dynamic)

17,544

If there is one cell of your range which is always within your table, like A1 would be always top-left corner of the table. And if there is continuous range of cells until the end of your table you could use .CurrentRegion property in this way:

Set rng = dataSheet.Range("A1").CurrentRegion
Share:
17,544
Mitchell Walker
Author by

Mitchell Walker

Computer Science Major at Western Washington University

Updated on June 04, 2022

Comments

  • Mitchell Walker
    Mitchell Walker almost 2 years

    I have a program in VBA that I am working on that filters values from a table. I'm trying to make this a generic program that works with all tables that you give it. In my program I have to set the range of the table that it is filtering: Set rng = dataSheet.Range("A1:F78"). I was wondering if there was a way to get the Range of a table in excel that has some sort of text value in it so I don't have to specify it in every macro. I guess this is a type of dynamic range.