ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Controlling Excel From Access (https://www.excelbanter.com/excel-programming/412488-controlling-excel-access.html)

Keith Wilby

Controlling Excel From Access
 
I have an Access app that creates a new worksheet in the workbook chosen by
the user via a dialog box. I would like the new worksheet to appear at the
end of the existing collection of worksheets. Would anyone happen to know
the syntax for getting a count of sheets in the current workbook and using
that count to place the new sheet at the end?

Many thanks.

Keith.


dennis

Controlling Excel From Access
 
xlApp is a reference to the currently opened Excel workbook and xlWS is the
reference to the new sheet you have added

xlWS.Move After:=xlApp.Worksheets(xlApp.Worksheets.Count)

"Keith Wilby" wrote:

I have an Access app that creates a new worksheet in the workbook chosen by
the user via a dialog box. I would like the new worksheet to appear at the
end of the existing collection of worksheets. Would anyone happen to know
the syntax for getting a count of sheets in the current workbook and using
that count to place the new sheet at the end?

Many thanks.

Keith.



Keith Wilby

Controlling Excel From Access
 
"Dennis" wrote in message
...
xlApp is a reference to the currently opened Excel workbook and xlWS is
the
reference to the new sheet you have added

xlWS.Move After:=xlApp.Worksheets(xlApp.Worksheets.Count)


Dennis, thank you, just the job.

Regards,
Keith.



All times are GMT +1. The time now is 02:05 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com