Hi,
I am developing a static mathematical model that will determine the annual energy consumption of an air handling unit based on user input.
The model calculates the energy consumption of each of the components (Fans, Pre-heating coil, Cooling coil, Re-heating coil and Humidifier) for every hour of a given year.
The model requires two main data inputs: the user input-parameters (indoor setpoints for temperature, humidity etc.) and climate-data (outside temperature, humidity etc.).
The climate data is provided as a .txt file with hourly records for each period and location, a single period spanning one decade (e.g. 2011 - 2020). These 10-year datasets contain 87600 rows of data.
There is also the current period, being 2021 - 2030, which contains 8760 rows (2021) + all of 2022's hourly records up to today (about 12000 - 13000 total at the moment).
See image 1 below for an example of the original formatting.
Image 1: example dataset
I've used the macro recorder to record me manually importing a dataset with the legacy text import-function. I've combined that code with a piece that promts the user to select a climate file, rather than having to go through the legacy import-function themselves. Then I used a counter to pull exactly 8760 rows of data from each of the aformentioned columns. See image 2:
Image 2: example of current solution
Now up to this point I haven't used VLOOKUP for this, there are IF-statements checking if the value in the 'counter'-column is between or equal to 1 and 8760, and if the statement is true the corresponding data gets pulled from the table on the left. For the temperatures the original values have to be divided by 10 to get the correct units for the model.
Above solution works for running periods, but it isn't ideal as Excel still imports thousands of unused rows (hourly data from 2022). Furthermore, I would like to be able to select a specific year from the larger 10-year datasets, for example the year 2013 from dataset 2011 - 2030.
What I came up with myself was to create an input-field in which the user can provide the first date of the climate year that has to be imported, for example: I would like to import the climate-data for the year 2013 so my input would be '01-01-2013'. Then I use VLOOKUP to pull the required data, being columns T, TD and U, from the correct year (starting at the provided start date + 8759 rows).
This solution works but it isn't feasable, I've only been able to realise this for one column (T). Excel becomes terribly slow and instable, possibly because of the size of the dataset and the number of 'VLOOKUP'-instances that need to be called (4 x 87600) to provide the user with the ability to pull a specific year from the dataset.
This got the thinking that it might be possible to use VBA to prompt the user to select a file with the Windows Explorer and be able to select which climate year has to be imported using a user input. The input can be a date or value range, e.g. '01-01-2013 - 31-12-2013', or '01-01-2013' +8759 (hours, records)', or just the hours. Any form in which the user can specifcy a specific year, and thus prevent Excel from importing the complete 10-year dataset.
Any help, insights or tips are greatly appreciated!
Thanks in advance
I am developing a static mathematical model that will determine the annual energy consumption of an air handling unit based on user input.
The model calculates the energy consumption of each of the components (Fans, Pre-heating coil, Cooling coil, Re-heating coil and Humidifier) for every hour of a given year.
The model requires two main data inputs: the user input-parameters (indoor setpoints for temperature, humidity etc.) and climate-data (outside temperature, humidity etc.).
The climate data is provided as a .txt file with hourly records for each period and location, a single period spanning one decade (e.g. 2011 - 2020). These 10-year datasets contain 87600 rows of data.
There is also the current period, being 2021 - 2030, which contains 8760 rows (2021) + all of 2022's hourly records up to today (about 12000 - 13000 total at the moment).
See image 1 below for an example of the original formatting.
Image 1: example dataset
I've used the macro recorder to record me manually importing a dataset with the legacy text import-function. I've combined that code with a piece that promts the user to select a climate file, rather than having to go through the legacy import-function themselves. Then I used a counter to pull exactly 8760 rows of data from each of the aformentioned columns. See image 2:
Image 2: example of current solution
Now up to this point I haven't used VLOOKUP for this, there are IF-statements checking if the value in the 'counter'-column is between or equal to 1 and 8760, and if the statement is true the corresponding data gets pulled from the table on the left. For the temperatures the original values have to be divided by 10 to get the correct units for the model.
Above solution works for running periods, but it isn't ideal as Excel still imports thousands of unused rows (hourly data from 2022). Furthermore, I would like to be able to select a specific year from the larger 10-year datasets, for example the year 2013 from dataset 2011 - 2030.
What I came up with myself was to create an input-field in which the user can provide the first date of the climate year that has to be imported, for example: I would like to import the climate-data for the year 2013 so my input would be '01-01-2013'. Then I use VLOOKUP to pull the required data, being columns T, TD and U, from the correct year (starting at the provided start date + 8759 rows).
This solution works but it isn't feasable, I've only been able to realise this for one column (T). Excel becomes terribly slow and instable, possibly because of the size of the dataset and the number of 'VLOOKUP'-instances that need to be called (4 x 87600) to provide the user with the ability to pull a specific year from the dataset.
This got the thinking that it might be possible to use VBA to prompt the user to select a file with the Windows Explorer and be able to select which climate year has to be imported using a user input. The input can be a date or value range, e.g. '01-01-2013 - 31-12-2013', or '01-01-2013' +8759 (hours, records)', or just the hours. Any form in which the user can specifcy a specific year, and thus prevent Excel from importing the complete 10-year dataset.
Any help, insights or tips are greatly appreciated!
Thanks in advance