MwTV
MIS
- Mar 9, 2007
- 99
Using Excel 2002 and occasionally run complex queries and drop the result in Excel templates.
Problem is when the order of columns in the query result do not coincide with the column headings in the Excel templates. Therefore, I have to manually cut and paste the columns in the query result to coincide with the columns in the Excel template. (Note, some of the query results are over 30,000 records) Then, I copy the query result to the Excel Template.
Question - Is it possible to enter the column headings (in the desired order using Excel copy/transpose feature) in column "A" of the worksheet that contains the query results and have a macro or vba to rearrange the query result data that is in columns “B” through “D” so that the columns now coincide with the order of the data in my Excel template?
For example, if I have the following entered in columns “B” through “D” of my query result set;
Name---State-----City
Jill---Nevada----LasVegas
Seth---Illinois--Chicago
Mary---Florida----Miami
and the columns in my excel template are
Name
City
State
Therefore, my desired result would be for the columns in my query result set to be
Name---City-------State
Jill---LasVegas---Nevada
Seth---Chicago----Illinois
Mary---Miami------Florida
Can this be done?
Thanks in advance.
Problem is when the order of columns in the query result do not coincide with the column headings in the Excel templates. Therefore, I have to manually cut and paste the columns in the query result to coincide with the columns in the Excel template. (Note, some of the query results are over 30,000 records) Then, I copy the query result to the Excel Template.
Question - Is it possible to enter the column headings (in the desired order using Excel copy/transpose feature) in column "A" of the worksheet that contains the query results and have a macro or vba to rearrange the query result data that is in columns “B” through “D” so that the columns now coincide with the order of the data in my Excel template?
For example, if I have the following entered in columns “B” through “D” of my query result set;
Name---State-----City
Jill---Nevada----LasVegas
Seth---Illinois--Chicago
Mary---Florida----Miami
and the columns in my excel template are
Name
City
State
Therefore, my desired result would be for the columns in my query result set to be
Name---City-------State
Jill---LasVegas---Nevada
Seth---Chicago----Illinois
Mary---Miami------Florida
Can this be done?
Thanks in advance.