I'm sketching out a cool generic tool (probably destined to be an Add-In) that will create a report using data from other sheets in the current workbook. More detail on that in a minute, but first right to my question:
For a given worksheet, how can I reliably identify the block of cells containing the headers? Assumptions: the worksheet contains one block of data with one header row, the header row is probably not on row one, and there may be miscellaneous data above the header row (worksheet titles, Subtotal formulas, etc). Because this is for a generic tool that can be used in any workbook, assume I'll know nothing else about the sheet.
In case you care why I'm asking: my code will be creating a sheet with dropdown boxes in each column of row one that will be dynamically populated with the names of all other sheets in the current workbook. That's easy enough, but once the user selects a sheet name in a given column, I want to populate another dropdown box (in row 2 of that same column) with the column headers from the specified sheet (thus my question).
Once the user selects the desired column, my code will go out and copy the data in that column to the report sheet. The idea is to have an on-the-fly report builder where columns can be swapped in and out like building blocks. Similar in flexibility to a Pivot Table, but the final result is a standard worksheet.
As always, thanks in advance for your invaluable input!
VBAjedi
For a given worksheet, how can I reliably identify the block of cells containing the headers? Assumptions: the worksheet contains one block of data with one header row, the header row is probably not on row one, and there may be miscellaneous data above the header row (worksheet titles, Subtotal formulas, etc). Because this is for a generic tool that can be used in any workbook, assume I'll know nothing else about the sheet.
In case you care why I'm asking: my code will be creating a sheet with dropdown boxes in each column of row one that will be dynamically populated with the names of all other sheets in the current workbook. That's easy enough, but once the user selects a sheet name in a given column, I want to populate another dropdown box (in row 2 of that same column) with the column headers from the specified sheet (thus my question).
Once the user selects the desired column, my code will go out and copy the data in that column to the report sheet. The idea is to have an on-the-fly report builder where columns can be swapped in and out like building blocks. Similar in flexibility to a Pivot Table, but the final result is a standard worksheet.
As always, thanks in advance for your invaluable input!
VBAjedi