+ Reply to Thread
Results 1 to 5 of 5

Go to last modified cell in other worksheets

  1. #1
    Registered User
    Join Date
    12-16-2020
    Location
    London
    MS-Off Ver
    Office 365
    Posts
    28

    Go to last modified cell in other worksheets

    Hi,

    Im trying to create a code that takes me to the last modified cell between all other worksheets (except the active worksheet). i have the below code but its not working.

    any help to rectify would be much appreciated.

    PHP Code: 
    Option Explicit

    Sub GoToLastModifiedCell
    ()
        
    Dim ws As Worksheet
        Dim lastModifiedCell 
    As Range

        
    'Loop through all worksheets except the active one
        For Each ws In ThisWorkbook.Worksheets
            If ws.Name <> ActiveSheet.Name Then
                '
    Check if the worksheet has a last modified cell
                
    If ws.Cells.Find("*"SearchOrder:=xlByRowsSearchDirection:=xlPreviousIs Nothing Then
                    
    'If not, go to the next worksheet
                    GoTo NextSheet
                End If
                '
    If the worksheet has a last modified cellcheck if it's the most recent
                If lastModifiedCell Is Nothing Then
                    Set lastModifiedCell = ws.Cells.Find("*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious)
                ElseIf ws.Cells.Find("*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Modified > lastModifiedCell.Modified Then
                    Set lastModifiedCell = ws.Cells.Find("*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious)
                End If
            End If
    NextSheet:
        Next ws
        '
    Go to the last modified cell
        lastModifiedCell
    .Active
    End Sub 
    Kind Regards
    Danny

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    49,042

    Re: Go to last modified cell in other worksheets

    What do you mean by "last modified cell"?

    Is it the last cell in a column? Or row?

    You could have a Workbook Sheeting Change Event handler that stores the sheet name, address, date/time and value in a log sheet. You could log every change, or just the most recent change for each sheet.
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  3. #3
    Registered User
    Join Date
    12-16-2020
    Location
    London
    MS-Off Ver
    Office 365
    Posts
    28

    Re: Go to last modified cell in other worksheets

    Hi Trevor,

    Last modified cell meaning the cell that was last changed within the work book (excluding any changes in the active worksheet, so basically visually the worksheet changes to the cell on another worksheet).

    in principle that sounds like it would work, as it could sort through the worksheets and identify the most recent change (excluding the active worksheet) and then go to that next worksheet and cell.

    would you know how to do this?

    Kind Regards

  4. #4
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    49,042

    Re: Go to last modified cell in other worksheets

    I suspect that you are confusing what is meant by the Active Sheet. The Active Sheet is the sheet manually selected and the Active Cell is a cell in the Selected range on the Active Sheet.

    You can make changes to a cell or range on any sheet using VBA but that won't necessarily be the Active Sheet or the Active Cell. You can, of course, make changes to more than one cell on any sheet. For example, if you clear a range or use an Array Formula.

    You need to consider what you want to happen of someone (maybe you) selects a large range, or even the whole sheet, and presses Delete.

  5. #5
    Valued Forum Contributor
    Join Date
    08-08-2022
    Location
    Buenos Aires
    MS-Off Ver
    Excel 2019
    Posts
    1,777

    Re: Go to last modified cell in other worksheets

    Hello.
    I'll show you an example: what you write in the first two sheets will be recorded in the 'Change Log' sheet:

    Please Login or Register  to view this content.
    Attached Files Attached Files
    You are always very welcome if you add reputation by clicking the * (bottom left) of each message that has helped you.

+ 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] VBA to have Modified by and Modified on column for all rows
    By gmalpani in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 07-28-2020, 03:21 PM
  2. Compare 2 Excel Worksheets & Show Items Added, Removed & Modified
    By puls8 in forum Excel Programming / VBA / Macros
    Replies: 27
    Last Post: 11-13-2014, 02:02 AM
  3. Replies: 3
    Last Post: 08-16-2014, 09:55 AM
  4. [SOLVED] Prompt input of future date in cell when another cell has been populated or modified
    By coffeemints in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-07-2013, 06:46 PM
  5. Replies: 0
    Last Post: 01-29-2013, 04:59 PM
  6. Summary All Worksheets With Formulas - Ron De Bruin modified
    By al007 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-13-2006, 04:50 PM
  7. Getting last Modified documents/worksheets
    By Bonzy in forum Excel General
    Replies: 1
    Last Post: 03-03-2005, 12:06 AM

Tags for this Thread

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