+ Reply to Thread
Results 1 to 5 of 5

penultimate sheet

Hybrid View

  1. #1
    Forum Contributor max_max's Avatar
    Join Date
    06-28-2013
    Location
    italy - venice
    MS-Off Ver
    Excel 2007
    Posts
    1,693

    penultimate sheet

    Hello,
    there is a function that I excel at the end of the penultimate leaf selection changed?
    This:

    Sheets ("Sheet1"). Select

    select only sheet1, but I want the penultimate sheet changed, which can be Sheet5, or Sheet3 etc ...
    I hope I explained.
    Thank you,
    max_max
    ---------------------------------------------------------------------------------------------------------------
    Ciao,
    c'è una funzione che alla chiusura di excel mi selezione il penultimo foglio modificato?
    Questo:

    Sheets("Foglio1").Select

    seleziona solo foglio1, ma io vorrei sul penultimo foglio modificato, che può essere foglio5, oppure foglio3 ecc...
    Spero di essermi spiegato.
    Grazie,
    max_max

  2. #2
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,468

    Re: penultimate sheet

    Select one from last sheet.

    Sheets(sheets.count-1).select
    Cheers
    Andy
    www.andypope.info

  3. #3
    Forum Contributor max_max's Avatar
    Join Date
    06-28-2013
    Location
    italy - venice
    MS-Off Ver
    Excel 2007
    Posts
    1,693

    Re: penultimate sheet

    Thanks for your help Andy Pope.
    No, the formula:
    Sheets (sheets.count-1). Select the workbook select the sheet 8 in the workbook.
    Must be the penultimate sheet changed.
    max_max
    ---------------------------------------------------------------------------------------------------------------
    Grazie dell'aiuto Andy Pope.
    No, la formula:
    Sheets(sheets.count-1).select nel workbook seleziona il foglio 8 nel workbook.
    Deve essere il penultimo foglio modificato..
    max_max

  4. #4
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,468

    Re: penultimate sheet

    standard code module
    Public gLastSheetChanged(1 To 2) As Worksheet
    Thisworkbook code module
    Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
    
        If Not gLastSheetChanged(1) Is Nothing Then
            Set gLastSheetChanged(2) = gLastSheetChanged(1)
        End If
        Set gLastSheetChanged(1) = Sh
            
    End Sub
    gLastSheetChanged(2) contains reference to penultimate sheet or Nothing if only 1 sheet changed.

  5. #5
    Forum Expert
    Join Date
    07-15-2012
    Location
    Leghorn, Italy
    MS-Off Ver
    Excel 2010
    Posts
    3,431

    Re: penultimate sheet

    My solution
    Dim n As Integer
    Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
    Sheets(n).Select
    End Sub
      
    Private Sub Workbook_SheetDeactivate(ByVal Sh As Object)
    n = Sh.Index
    End Sub
    If solved remember to mark Thread as solved

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Return penultimate value in a range
    By Alan 87 in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 12-23-2014, 08:14 AM
  2. [SOLVED] Penultimate Value in Column
    By Fletch74 in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 06-01-2014, 07:26 PM
  3. [SOLVED] Return penultimate value in a range
    By Sophie.Durrant in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 07-05-2013, 07:00 AM
  4. reverse lookup - last value & penultimate value
    By bowgieman in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 06-28-2013, 10:17 AM
  5. Penultimate, Second Value in a range
    By Bob@Sun in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 12-28-2009, 04:25 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1