Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 96
Default 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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default 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



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27
Default 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
.

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Referencing data across sheets RDR Excel Worksheet Functions 2 September 25th 08 01:30 PM
Referencing sheets Techclerk Excel Discussion (Misc queries) 4 May 26th 08 12:25 AM
When referencing other Sheets JT Excel Discussion (Misc queries) 1 March 14th 07 05:36 PM
Referencing Different Sheets in VBA [email protected] Excel Discussion (Misc queries) 4 September 1st 06 05:57 AM
Referencing Sheets Eric[_14_] Excel Programming 1 December 2nd 03 07:44 PM


All times are GMT +1. The time now is 03:32 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"