I am trying to pull data from a database. I have a really large table on SQL Server that I query using MS Query. I would like to pull from columns based on a list from excel that changes based on another field.
Here is an example. The table in SQL Server contains columns A through Z. I would have an input range of the columns I would pull down from SQL Server and only these columns.
For example cells A1:A4 in Excel would have the following (the range for the pull would be A2:A10. A5:A10 would be blank for this example):
Columns
Column_B
Column_D
Column_G
<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com
ffice
ffice" /><o
></o
>
The query would only pull these 3 columns. However, if I change the list and refresh, it would pull the new list of columns.
<o
></o
>
I currently pull down the entire table through MS Query but the problem is the table has about 300 columns and I really only need a third of them at any given time. I do not think I can do it dynamically through MS Query but I could be wrong.
<o
></o
>
I know about using parameters in criteria to limit the observations pulled dynamically using “[]”. However, I am not sure how to dynamically pull columns.
<o
></o
>
Please let me know if you have any ideas. I would be happy to use VBA, just not sure how to do it.
<o
></o
>
Thank you in advance for your help.
Scott
Here is an example. The table in SQL Server contains columns A through Z. I would have an input range of the columns I would pull down from SQL Server and only these columns.
For example cells A1:A4 in Excel would have the following (the range for the pull would be A2:A10. A5:A10 would be blank for this example):
Columns
Column_B
Column_D
Column_G
<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com




The query would only pull these 3 columns. However, if I change the list and refresh, it would pull the new list of columns.
<o


I currently pull down the entire table through MS Query but the problem is the table has about 300 columns and I really only need a third of them at any given time. I do not think I can do it dynamically through MS Query but I could be wrong.
<o


I know about using parameters in criteria to limit the observations pulled dynamically using “[]”. However, I am not sure how to dynamically pull columns.
<o


Please let me know if you have any ideas. I would be happy to use VBA, just not sure how to do it.
<o


Thank you in advance for your help.
Scott