+ Reply to Thread
Results 1 to 8 of 8

Need macro to highlight cells with nonsequential function

  1. #1
    Registered User
    Join Date
    12-23-2012
    Location
    Knoxville, TN
    MS-Off Ver
    Excel 2010
    Posts
    57

    Need macro to highlight cells with nonsequential function

    I have am trying to create a macro that highlights cells containing formulas with components that are out of sequence within a column.
    Trace Precedents does not readily reveal some of these errors because the traces can overlap.
    GoToSpecial, Precedents, All Levels has the same problem.
    Here is an example of what I want to happen, so that I can find an error:
    formulaCheck.JPG
    Here is a portion of Excel spreadsheet I'm dealing with: QAformulasFORUM.xlsm
    Currently, all the formulas I'm dealing with refer to cells within the same spreadsheet.
    I realize a cell with a function unlike the cells near it usually has a green corner, but a) my eyes may not catch them, and b) cell error flagging may have been turned off at some point in some ranges.
    I appreciate anyone's input!
    burnettec

  2. #2
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Need macro to highlight cells with nonsequential function

    The code below creates a sheet following the active sheet with a character in each used cell that characterizes the contents. In column M, for example, it shows that you have formulas copied down from above, interspersed with other formulas. I keep this in Personal and have the shortcut Ctrl+Shift+M (for Map) assigned.

    Please Login or Register  to view this content.
    Entia non sunt multiplicanda sine necessitate

  3. #3
    Forum Expert OllieB's Avatar
    Join Date
    12-20-2012
    Location
    Netherlands
    MS-Off Ver
    Excel 2007 (home) & 2010 (office)
    Posts
    1,542

    Re: Need macro to highlight cells with nonsequential function

    If you use .DirectPrecedents on a cell containing a formula, it returns a range object within n areas that relate to the elements/references of the formula. Should each reference not refer to the same row as the parent cell? The exception would be the lookup ranges but those addresses are known and fixed so should be easy to exclude from the process. Using this logic it was for example easy to find errors such as in cell M27. Using Find Special it is relatively easy for find all formulas on the worksheet. Would that help?
    If you like my contribution click the star icon!

  4. #4
    Registered User
    Join Date
    12-23-2012
    Location
    Knoxville, TN
    MS-Off Ver
    Excel 2010
    Posts
    57

    Re: Need macro to highlight cells with nonsequential function

    Ollie, it seems to me that a macro incorporating .DirectPrecedents code might be the same as using "show formulas" in the formula auditing tab, which I have done. My concern is that the spreadsheet will still be so busy that my eye will not be able to catch any unwanted formula deviations. I guess my problem is that the data set is quite large and has a lot of different series of formulas. Not saying your idea isn't superior and valid, just that I may not have the expertise to use it properly.

    shg, your macro is so cool. I tested it and found formatting errors I didn't even know existed in my original spreadsheet. Errors I intentionally placed did not show up as red, but were a different character than the surrounding cells. So, even if I found just one different character (error) in a column with many errors (some I missed after the macro was run), I could filter for that character and identify all of them. I think this will work for me.

    Thank you both so much. I've learned a lot from this thread.

  5. #5
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Need macro to highlight cells with nonsequential function

    Errors I intentionally placed did not show up as red, but were a different character than the surrounding cells.
    That was due for a clean-up anyway:

    Please Login or Register  to view this content.

  6. #6
    Registered User
    Join Date
    12-23-2012
    Location
    Knoxville, TN
    MS-Off Ver
    Excel 2010
    Posts
    57

    Re: Need macro to highlight cells with nonsequential function

    Aw, shg, hope you didn't take unnecessary time to edit your super macro on my account. I was happy with the first one. Thanks for the update though. Thanks to your response earlier today, I got my error-checking done a day earlier than expected! Yea! Now I'll have time to run errands before Monday!

  7. #7
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Need macro to highlight cells with nonsequential function

    You're welcome. There a version with some cleanup and a few more bells and whistles at https://www.box.com/s/z6qv4zbz8xy17d5ziesn.

    It's a .bas file; dowload to a folder, and then drag it into the VBA project for the selected workbook.
    Last edited by shg; 01-27-2013 at 06:40 PM.

  8. #8
    Registered User
    Join Date
    12-23-2012
    Location
    Knoxville, TN
    MS-Off Ver
    Excel 2010
    Posts
    57

    Re: Need macro to highlight cells with nonsequential function

    Thank you. You're a big hit at my office now!

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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