Hello, I am trying to create new queries based on the values in a range of cells using VBA.
So far I have got the creation bit working (which I thought would be the hardest part), however I can't seem to skip an iteration if the query already exists.
I have a entries in a range of cells which will grow over time. The contents of the cells hint to the location of the source file for the query and its name (eg "C 2024-01-31" indicates a specific folder to grab the file from and will be the name of the resultant query also). I have managed to create the part of the macro which locates the file and imports it.
However, if I were to re-run the code again I get 'query already exists' error.
Over time as the list of cells grows, I want to create more queries based on new entries. Obviously I don't want to create queries if they already exist.
I should add that there other queries which already exist in the workbook for other purposes which have no relevance to the range of cells - so I need to check based on my range of cells and not vice versa...
Can someone help me with VBA to run through the list of cells, create the query if it doesn't exist, BUT ignore that value if the query already exists and move to the next item in the list..?
Thanks, David
So far I have got the creation bit working (which I thought would be the hardest part), however I can't seem to skip an iteration if the query already exists.
I have a entries in a range of cells which will grow over time. The contents of the cells hint to the location of the source file for the query and its name (eg "C 2024-01-31" indicates a specific folder to grab the file from and will be the name of the resultant query also). I have managed to create the part of the macro which locates the file and imports it.
However, if I were to re-run the code again I get 'query already exists' error.
Over time as the list of cells grows, I want to create more queries based on new entries. Obviously I don't want to create queries if they already exist.
I should add that there other queries which already exist in the workbook for other purposes which have no relevance to the range of cells - so I need to check based on my range of cells and not vice versa...
Can someone help me with VBA to run through the list of cells, create the query if it doesn't exist, BUT ignore that value if the query already exists and move to the next item in the list..?
Thanks, David