View Full Version : Head fogged truly by Excel worksheet move problem


alecwood
02-12-2008, 05:25 AM
Hi All

I am exporting a series of queries from my database to Excel as part of a report.

Easy stuff using the TransferSpreadsheet Method. Now the boss wants some of these queries displayed together on a singleworksheet sheet, and some on individual ones. Here's my methodology

I output a couple of queries using the TransferSpreadsheet method
Then I use ADO to read each of three queries and use the CopyFromRecordset method to dump them into a new worksheet, then a few more TransferSpreadsheet and one more set of four CopyFromRecordset

My problem is this - the two worksheets I add and fill using ADO are at the front of the workbook, not where I want them to be. I need to move these worksheets to the appropriate place in the report.

Any ideas? I got this off another forum but it does not work

oapp.worksheets("Sheet5").Move.After = "Sheet4"

I have a suspicion it's almost right, but no variation I have tried has worked yet.

chergh
02-12-2008, 05:35 AM
oapp.worksheets("Sheet5").Move After:= oapp.worksheets("Sheet4")

alecwood
02-12-2008, 05:46 AM
Woo Hoo !

Now I can finally get a coffee in peace

Many thanks for your help