+ Reply to Thread
Results 1 to 7 of 7

audit log VBA code not capturing IF formula result

  1. #1
    Registered User
    Join Date
    05-21-2009
    Location
    South Africa
    MS-Off Ver
    Excel 2010
    Posts
    4

    audit log VBA code not capturing IF formula result

    I have an audit log VBA code, to capture changes from several worksheets into one worksheet called "LRLog".

    This only writes value changes. Formatting changes are not required to be captured.

    The VBA code works fine, but does NOT capture changes in those cells which are determined by IF formula based on data input in other cells.

    Users will make changes in columns C, D, E, F, and H, with IF formula in columns A and G showing a result, dependent on the data input in columns D, E, and F.
    However, currently, any changes to cols A or G (because of the outcome of formulae in col A or G) are not captured in the audit log, as attached:
    (yellow blocks in the attached Audit log are what is expected should be displayed).

    The following VBA has been used in the sheets where changes will take place.
    ------------------------------------------
    Please Login or Register  to view this content.
    ------------------------------------

    Can anyone help with the VBA code so that any changes to cols A or G (because of the outcome of formulae in col A or G) are also captured in the audit log?

    I would also like to include good error handling in this project if possible.
    Attached Files Attached Files
    Last edited by AliGW; 04-12-2018 at 04:41 AM. Reason: Code tags added - you must do this yourself in future, please.

  2. #2
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: audit log VBA code not capturing IF formula result

    Any chance you could upload a sample workbook?

    Click on GO ADVANCED, scroll down and click Manage Attachments.

    PS When posting code can you please use CODE tags?
    If posting code please use code tags, see here.

  3. #3
    Registered User
    Join Date
    05-21-2009
    Location
    South Africa
    MS-Off Ver
    Excel 2010
    Posts
    4

    Re: audit log VBA code not capturing IF formula result

    Apologies for non-Code tag usage, but I have no experience with VBA and have been doing a Copy & Paste of VBA code, using the web page below as a starter, and adapting other VBA as I find and where I think they may fit:
    Mr Excel web page - "VBA Code to create an audit trail in Excel 2010"

    In the interim, I have reduced the number of audit columns to the following.

    Who
    Sheet
    Cell(s)
    Changed FROM
    Changed TO
    Date
    Time

    Attached is a sample workbook, with Sheets "LR", "AD", and "LRLog" (the audit log);
    LR = (basically a test page to see if whatever is typed on this particular sheet is captured in the audit log);
    AD = is a section of the worksheet that I intend using.
    Attached Files Attached Files

  4. #4
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: audit log VBA code not capturing IF formula result

    The Change event of a worksheet is not triggered when a value changes due to the result of a formula.

    What formula(s) do you have in column A & G?

  5. #5
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: audit log VBA code not capturing IF formula result

    Hi, I found this tracking log on Ozgrid's site (is mentioned in the code), works for me, you will probably have to tailor it to your needs but is does also mention formula resuls.
    Please Login or Register  to view this content.
    I suggest you visit that site for further information.
    ---
    Hans
    "IT" Always crosses your path!
    May the (vba) code be with you... if it isn't; start debugging!
    If you like my answer, Click the * below to say thank-you

  6. #6
    Registered User
    Join Date
    05-21-2009
    Location
    South Africa
    MS-Off Ver
    Excel 2010
    Posts
    4

    Re: audit log VBA code not capturing IF formula result

    For example:
    In Cell A7: =IF(G7="REPEALED","REPEALED",L7)

    In Cell G7: =
    IF(AND(L7="Compliance",D7="R",E7="R",F7="R"),"REPEALED",
    IF(AND(L7="Compliance",D7=1,E7="",F7=""),"Compliant",
    IF(AND(L7="Compliance",D7="",E7=1,F7=""),"Semi-compliant",
    IF(AND(L7="Compliance",D7="",E7="",(OR(F7=1,F7=""))),"NON-COMPLIANT",

    IF(AND(L7="Must",D7="R",E7="R",F7="R"),"REPEALED",
    IF(AND(L7="Must",D7="",E7="",F7=""),"CRITICAL IF NON-Compliant",
    IF(AND(L7="Must",D7=1,E7="",F7=""),"Compliant",
    IF(AND(L7="Must",D7="",E7="",(OR(F7=1,F7=""))),"CRITICAL IF NON-Compliant",

    IF(AND(L7="Heading",D7="",E7="",F7=""),"Heading",
    IF(AND(L7="Info",D7="",E7="",F7=""),"Info",

    IF(AND(L7="Info",D7="R",E7="R",F7="R"),"REPEALED",
    IF(AND(L7="Heading",D7="R",E7="R",F7="R"),"REPEALED",

    IF(NOT(OR(AND(L7="Heading",D7="R",E7="R",F7="R"),AND(L7="Heading",D7="",E7="",F7=""))=TRUE),"ERROR",
    IF(NOT(OR(AND(L7="Info",D7="R",E7="R",F7="R"),AND(L7="Info",D7="",E7="",F7=""))=TRUE),"ERROR",

    "CHECK VALUE & INSERT EXPLANATION"))))))))))))))

  7. #7
    Registered User
    Join Date
    05-21-2009
    Location
    South Africa
    MS-Off Ver
    Excel 2010
    Posts
    4

    Re: audit log VBA code not capturing IF formula result

    Hi Keebellah, that does not work for me.
    The initial code works better for me, save for the problem in not capturing changes in the IF formula.

+ 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] Unique counter based on the location code and time of an audit
    By quentin5000 in forum Excel Formulas & Functions
    Replies: 9
    Last Post: 02-02-2018, 04:00 AM
  2. VBA code for audit trail issue
    By TheGrinch1 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 06-11-2015, 08:06 AM
  3. Assistance with Audit code...
    By ciresuark in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 03-26-2015, 01:26 PM
  4. [SOLVED] Code result wrong but formula correct result
    By marreco in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 09-11-2014, 12:26 PM
  5. VBA code for Audit schedule email-weekly
    By Hense in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 05-27-2012, 04:42 AM
  6. [SOLVED] Web Query - Submitting Data and Capturing Result
    By Ben in forum Excel General
    Replies: 1
    Last Post: 04-29-2012, 10:12 AM
  7. stock audit & bar code scanner
    By joemahony in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 05-28-2008, 12:53 AM

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