I am using this code to bring in excel data. I'd like to "enhance" it as currently I have to switch to excel to change a cell number so that the data set I want to import is "refreshed".
In excel I have a number in Cell H1. Each time I click the import button on the Access form, I would like to be able to choose a number, enter it in a text box on the Access form and have that number placed into cell H1 of the spreadsheet so that the transfer spreadsheet code will pick up the selected data. The named range in excel is called DataSet2006. There are three cols that are affected by the number reflected by Cell H1. For example if I type a 5 in cell H1, then the formulas within the Named Range will look at data in Col P (The 5th col from the start point [Col L].
=(INDEX($L$2:$IV$2,1,$H$1))
=(INDEX($L$3:$IV$3,1,$H$1))
=(INDEX($L4:$IV4,1,$H$1))
The access button and excel formula are working fine, but I have to switch to excel, change the number, then switch back to access click on the import button I created, then swicth back to excel, so if I can refer or pass the number needed by Excel in cell H1, then the process can be quicker.
I am using this to transpose a lot of data into a simple table. If this can be done, then perhaps it could be further enhanced with a loop so that if I have 50 cols of data, I can have it start cell H1 with the number 1 and then increment to 2, 3, 4..,50.
I already tried a pivot table, but it didn't quite seem to give me what I needed, or I didn't quite know how to fully use it. Thread: Pivot Tables Multiple Consolidation Ranges
Code:
Private Sub btnImportExcel_Click()
DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel9, "DataSet2006", "\\Discimageserver\DataStats\2006Conversion.XLS", True, "DataSet2006"
End Sub
In excel I have a number in Cell H1. Each time I click the import button on the Access form, I would like to be able to choose a number, enter it in a text box on the Access form and have that number placed into cell H1 of the spreadsheet so that the transfer spreadsheet code will pick up the selected data. The named range in excel is called DataSet2006. There are three cols that are affected by the number reflected by Cell H1. For example if I type a 5 in cell H1, then the formulas within the Named Range will look at data in Col P (The 5th col from the start point [Col L].
=(INDEX($L$2:$IV$2,1,$H$1))
=(INDEX($L$3:$IV$3,1,$H$1))
=(INDEX($L4:$IV4,1,$H$1))
The access button and excel formula are working fine, but I have to switch to excel, change the number, then switch back to access click on the import button I created, then swicth back to excel, so if I can refer or pass the number needed by Excel in cell H1, then the process can be quicker.
I am using this to transpose a lot of data into a simple table. If this can be done, then perhaps it could be further enhanced with a loop so that if I have 50 cols of data, I can have it start cell H1 with the number 1 and then increment to 2, 3, 4..,50.
I already tried a pivot table, but it didn't quite seem to give me what I needed, or I didn't quite know how to fully use it. Thread: Pivot Tables Multiple Consolidation Ranges