I have some VBA code that extracts data from my Access database, opens a new Excel workbook, adds column headers, and then puts the extracted data into the spreadsheet.
As part of this process, I use a counter to move from row to row.
I need to use the row count to select a range of cells to apply borders and set the print area since every time the data is extracted the range changes.
MyExcel.Range("A3:A+CurrentRow").Select
ActiveSheet.PageSetup.PrintArea = $A$3:$AM$CurrentRow
How do I put the row number in the range using the CurrentRow figure?
One other thing, how do I put the current date in the file name when I save the file via the VBA code?
For example, a report saved today would be:
Total_List_of_PPLs_02-11-04.xls
but a file saved tomorrow will need to have 02_12_04 there instead.
...
By the way, I don't have "CurrentRow" in my code as I haven't written the set print area section yet. It's just to show my problem.
Thanks in advance.
As part of this process, I use a counter to move from row to row.
I need to use the row count to select a range of cells to apply borders and set the print area since every time the data is extracted the range changes.
MyExcel.Range("A3:A+CurrentRow").Select
ActiveSheet.PageSetup.PrintArea = $A$3:$AM$CurrentRow
How do I put the row number in the range using the CurrentRow figure?

One other thing, how do I put the current date in the file name when I save the file via the VBA code?
For example, a report saved today would be:
Total_List_of_PPLs_02-11-04.xls
but a file saved tomorrow will need to have 02_12_04 there instead.
...
By the way, I don't have "CurrentRow" in my code as I haven't written the set print area section yet. It's just to show my problem.
Thanks in advance.
Last edited: