ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   referencing sheets (https://www.excelbanter.com/excel-programming/288932-referencing-sheets.html)

libby

referencing sheets
 
How do I reference the last worksheet in a workbook so
that the most recently added sheet is affected by my macro.

I've tried worksheets(sheet.count + 1)
but that doesn't seem to work.



Also how can I get my inserted sheet to always be on the
far right. They seem to pop in randomly at the moment.


Cheers guys

Ron de Bruin

referencing sheets
 
I've tried worksheets(sheet.count + 1)
You are close

Sheets(Sheets.Count).Select

Change Sheets to Worksheets if you have also Chart sheets in the workbook


--
Regards Ron de Bruin
(Win XP Pro SP-1 XL2000-2003)
www.rondebruin.nl



"libby" wrote in message ...
How do I reference the last worksheet in a workbook so
that the most recently added sheet is affected by my macro.

I've tried worksheets(sheet.count + 1)
but that doesn't seem to work.



Also how can I get my inserted sheet to always be on the
far right. They seem to pop in randomly at the moment.


Cheers guys




Brad[_10_]

referencing sheets
 
This code goes in the Workbook module.

Private Sub Workbook_NewSheet(ByVal Sh As Object)
Sh.Move After:=Worksheets
(ThisWorkbook.Worksheets.Count)
End Sub

Is this what you were looking for?

-Brad

-----Original Message-----
How do I reference the last worksheet in a workbook so
that the most recently added sheet is affected by my

macro.

I've tried worksheets(sheet.count + 1)
but that doesn't seem to work.



Also how can I get my inserted sheet to always be on the
far right. They seem to pop in randomly at the moment.


Cheers guys
.



All times are GMT +1. The time now is 10:19 PM.

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