ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Using Macros to create pivot tables - query re last row (https://www.excelbanter.com/excel-programming/358701-using-macros-create-pivot-tables-query-re-last-row.html)

chubbycheeks

Using Macros to create pivot tables - query re last row
 
I create reports in excel using large amounts of data extracted from a db on
a regular basis. I have created macros to convert this data and then create
pivot tables, again using a macro. I normally have to edit the macro each
time to select the correct amount of data - eg - R1C1:R7131C31 and the next
time there will be more/less rows - columns remain the same regardless. When
creating the macro, can i specify to automatically find the range which
contains only data - i.e. find the last row of data?


Duke Carey

Using Macros to create pivot tables - query re last row
 
Use the CurrentRegion property of the R1C1 range. It returns a range object
that consists of all the contiguous cells that contain data


"chubbycheeks" wrote:

I create reports in excel using large amounts of data extracted from a db on
a regular basis. I have created macros to convert this data and then create
pivot tables, again using a macro. I normally have to edit the macro each
time to select the correct amount of data - eg - R1C1:R7131C31 and the next
time there will be more/less rows - columns remain the same regardless. When
creating the macro, can i specify to automatically find the range which
contains only data - i.e. find the last row of data?



All times are GMT +1. The time now is 05:23 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com