+ Reply to Thread
Results 1 to 9 of 9

Alert when a formula gets changed.

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    11-30-2005
    Location
    Penzance Cornwall, UK
    MS-Off Ver
    Office 365
    Posts
    201

    Question Alert when a formula gets changed.

    Hi Guy's,

    I am helping someone tidy an existing workbook that has evolved over several years, there are bits of data spread all over the sheets and there are several sheets.

    My question is. Is there a way to show/print/email an alert with a reminder message any time any of the formula cells gets changed, something like "Be aware a formula is being changed, make a note of the changes."

    Your input would be appreciated,

    Keith

  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
    48,099

    Re: Alert when a formula gets changed.

    I've used this:

    Option Explicit
    
    Public bInTable As Boolean
    
    Private Sub Worksheet_Change(ByVal Target As Range)
    
    ' prevent changes to formula cells
    If Cells(1, Target.Column) <> "" Then
        If Not bInTable Then
            Exit Sub
        Else
            With Application
                .EnableEvents = False
                .Undo
                .EnableEvents = True
                MsgBox "Please do not make changes in this column", , _
                       "Changes not permitted"
                Exit Sub
            End With
        End If
    End If
    End Sub

    With this:

    Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    
    Dim lLR As Long
    
    ' establish range
    With Me
        ' last row of data based on column A
        lLR = .Range("A" & .Rows.Count).End(xlUp).Row
    End With
        
        If Target.Row <= lLR Then
            bInTable = True
        Else
            bInTable = False
        End If
    
    End Sub

    Basically, the Selection Change code determines if the cell selected is in the body of the table and sets a boolean flag. Then, if they make changes in the table area, the Worksheet Change event checks if row 1 is empty. If it's not, that column contains a formula ... the code undoes the change and displays a message.

    If they make changes outside the table area, I don't care.

    I have also considered checking the colour of the cell. In another project, I have used a Red interior colour to indicate that the column should not be changed and a Green interior colour to say that it can (take manual input) ... although I haven't put the protection code in place on this one.


    Regards, TMS
    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
    Forum Contributor
    Join Date
    11-30-2005
    Location
    Penzance Cornwall, UK
    MS-Off Ver
    Office 365
    Posts
    201

    Re: Alert when a formula gets changed.

    Thank you for a speedy reply.

    I "don't" want to "prevent" the changes to the formula, but I would like a prompt telling the user to make a note of any changes to a cell with a formula. Like you, I have color in the cells with formula, but we do need to change some of them and require a gentle reminder to make notes.

  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
    48,099

    Re: Alert when a formula gets changed.

    Ok, take out the undo bit and just leave the message.

    Think you're wasting your time though. The whole point of having formulae is to calculate stuff properly not to allow people to put whatever crap they want in. Anyway, your workbook, your issue

  5. #5
    Forum Contributor
    Join Date
    11-30-2005
    Location
    Penzance Cornwall, UK
    MS-Off Ver
    Office 365
    Posts
    201

    Re: Alert when a formula gets changed.

    Once again, thank you for a quick reply.

    I understand your point "The whole point of having formulae is to calculate stuff properly not to allow people to put whatever crap they want in" but the whole point of the exercise is to tidy a very messy workbook in which some of the formula have to change as we are adding/deleting columns & rows because the whole concept has changed, we are even considering, instead of the above, creating a whole new workbook from scratch.

  6. #6
    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
    48,099

    Re: Alert when a formula gets changed.

    ... instead of the above, creating a whole new workbook from scratch.
    If the concept has changed and its full of junk, you'd be better off starting afresh.

    Don't waste time, JFDI.


    Regards, TMS

  7. #7
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    53,048

    Re: Alert when a formula gets changed.

    Also, there are ways to construct formula that are proof against inserting/deleting columns/rows, but perhaps a fresh start might be better
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

  8. #8
    Forum Contributor
    Join Date
    11-30-2005
    Location
    Penzance Cornwall, UK
    MS-Off Ver
    Office 365
    Posts
    201

    Re: Alert when a formula gets changed.

    OK Guy's,

    After this discussion, I think my mind is made up, it is time to start again.......new workbook new problems.....watch this space!!

    Thank you both.

  9. #9
    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
    48,099

    Re: Alert when a formula gets changed.

    You're welcome. Thanks for the rep.

+ 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. Replies: 0
    Last Post: 10-10-2013, 05:14 AM
  2. FOrmula for alert when a certain time is reached
    By davemachews in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 04-19-2013, 03:19 AM
  3. New message alert... doesn't ALERT me very well
    By Xx7 in forum Outlook Formatting & Functions
    Replies: 6
    Last Post: 07-20-2011, 03:54 PM
  4. Formula for Alert or Message
    By tariqnaz2005 in forum Excel General
    Replies: 9
    Last Post: 12-09-2009, 04:42 AM
  5. Sound+color alert if cell changed in another worksheet
    By florinel in forum Excel General
    Replies: 0
    Last Post: 05-25-2006, 11:52 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