+ Reply to Thread
Results 1 to 14 of 14

Macro to identify a trend

  1. #1
    Registered User
    Join Date
    04-15-2013
    Location
    Sydney
    MS-Off Ver
    Excel 2003
    Posts
    9

    Macro to identify a trend

    Hi Team,

    This is well above my skill level....

    I have a range of data that I need to identify trends given certain input values...

    Data:-
    The Data is grouped in Weeks (Monday thru Sunday) each date has a value. Ie 5000, 6120, 7340, 2345, 7654, 6534, 3434 (1 Value per cell, left to rght)
    The data goes back 1 year...

    Why:-
    Each day I have to forecast what volumes we will be getting for the current + next 2 days.

    Requirements:-
    I want to be able to enter in a single value up to 3 values.
    The values are then compared to the data in the excel sheet with a variance. Meaning that I can set the variance in another cell.. ie 500. This would mean the formula / macro is to look at each cell and if there is a match that falls with the "500" then the row is highlight.

    Output:-
    Highlighted cell / Row

    Precision:-
    Matching the 3 cells with the variance of 500

    Really appreciate your help.. Thanks in advance.
    Witsend
    Attached Files Attached Files
    Last edited by Witsendestate; 04-15-2013 at 11:34 PM. Reason: Adding Excel 2007 example

  2. #2
    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
    52,929

    Re: Macro to identify a trend

    Hi and welcome to the forum

    this is the data you have in C3:C8, but for the moment, lets assume it goes across a row instead (its easier to copy this way lol)

    3232
    3615
    2777
    5394
    6377
    4545

    Based on that, you would want none of those highlighted because you dont have a "run" of 3 within your 500 range, BUT we used the values in E3:* instead...
    2130
    1356
    917
    1105
    958
    597

    then the values bolded with be highlighted?

    edit: if this IS what you are looking for, then, based on your data, you only get your 1st "run" of 3 when the variance value is 1200...

    the values in D8:G8...
    1735...597...475...1483
    ........1138...122...1008
    Last edited by FDibbins; 04-16-2013 at 12:08 AM.
    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

  3. #3
    Registered User
    Join Date
    04-15-2013
    Location
    Sydney
    MS-Off Ver
    Excel 2003
    Posts
    9

    Re: Macro to identify a trend

    FDibbins.. Thanks for the quick response...

    You raised a valid question... But what I was trying to ask is.. I have 3 values I enter.. ie 3000, 3500 & 2500

    The macro then scans each cell looking for a match based on those I entered but within a variance of 500.. Not a run of values <> 500.. so it would find in the one week the values 3232,3615 & 2777.
    Even if it finds 1, 2 or 3 close matches (within the 500 variance).. more the better..

    Make sense..

  4. #4
    Forum Expert
    Join Date
    01-15-2007
    Location
    Brisbane, Australia
    MS-Off Ver
    2007
    Posts
    6,591

    Re: Macro to identify a trend

    Hi

    In the range L3:L5 enter your 3 values (3000, 3500 and 2500). Then enter 500 in M2
    Highlight the range C3:I8 and then add 3 conditional formatting formulas
    =ABS(C3-$L$4) <=$M$2
    =ABS(C3-$L$3) <=$M$2
    =ABS(C3-$L$2)<=$M$2
    with different fill formats as required.

    This should highlight the relevant cells, and if you have different format colors, may also give you an indication which value it matches.

    HTH

    rylo

  5. #5
    Registered User
    Join Date
    04-15-2013
    Location
    Sydney
    MS-Off Ver
    Excel 2003
    Posts
    9

    Re: Macro to identify a trend

    Thanks Rylo.. Ill give this a shot.... You guys make it look so easy...

    Quote Originally Posted by rylo View Post
    Hi

    In the range L3:L5 enter your 3 values (3000, 3500 and 2500). Then enter 500 in M2
    Highlight the range C3:I8 and then add 3 conditional formatting formulas
    =ABS(C3-$L$4) <=$M$2
    =ABS(C3-$L$3) <=$M$2
    =ABS(C3-$L$2)<=$M$2
    with different fill formats as required.

    This should highlight the relevant cells, and if you have different format colors, may also give you an indication which value it matches.

    HTH

    rylo

  6. #6
    Registered User
    Join Date
    04-15-2013
    Location
    Sydney
    MS-Off Ver
    Excel 2003
    Posts
    9

    Re: Macro to identify a trend

    Quote Originally Posted by Witsendestate View Post
    Thanks Rylo.. Ill give this a shot.... You guys make it look so easy...
    Rylo & Team.... Thanks so much for your help.. Rylo's solution works perfectly..

  7. #7
    Registered User
    Join Date
    04-15-2013
    Location
    Sydney
    MS-Off Ver
    Excel 2003
    Posts
    9

    Re: Macro to identify a trend

    Team... Rylo's solution was perfect.. I now want to expand on it please..

    I would like to find 3 consecutive numbers in a row... The answer from Rylo will highlight each of the cells with an individual match but I would like to find if any cells next to each other fall within the variance...

    Your thoughts..

  8. #8
    Registered User
    Join Date
    04-15-2013
    Location
    Sydney
    MS-Off Ver
    Excel 2003
    Posts
    9

    Re: Macro to identify a trend

    This is what I tried:-

    =ABS(C6:I64-$N$4) <=$M$2 and <=$M$3 and <=$M$4

    The error I get is :- You may not use Unions, Intersections or Array Constants for Conditional Formatting

  9. #9
    Forum Expert
    Join Date
    01-15-2007
    Location
    Brisbane, Australia
    MS-Off Ver
    2007
    Posts
    6,591

    Re: Macro to identify a trend

    Hi

    Can you put up an example file, with some data and your comparison values and the comparison range, and the conditional formatting formulas from above (if they are still relevant) and advise which cells you would want highlighted and the reason for their highlighting.

    rylo

  10. #10
    Registered User
    Join Date
    04-15-2013
    Location
    Sydney
    MS-Off Ver
    Excel 2003
    Posts
    9

    Re: Macro to identify a trend

    Rylo,

    Here you go.. Your solution does work but just wondering if there is a single formula to do this instead of having multiple formula's..

    The spreadsheet attached cells c7,d7,e7 are highlighted as they fall in the range of the values given.

    Im also interested in having a "or" condition so it highlights 2 matches or 3 matches.

    Mark
    Attached Files Attached Files

  11. #11
    Forum Expert
    Join Date
    01-15-2007
    Location
    Brisbane, Australia
    MS-Off Ver
    2007
    Posts
    6,591

    Re: Macro to identify a trend

    Hi

    But do you want the range C7:E7 to be in a different color as there are 3 contiguous cells, or do you really just want to have one formula that covers off the 3 possible conditions?

    rylo

  12. #12
    Registered User
    Join Date
    04-15-2013
    Location
    Sydney
    MS-Off Ver
    Excel 2003
    Posts
    9

    Re: Macro to identify a trend

    Huh.. I sound like a typical end user:

    Both please.. ;-)

    If there are 3 in a row use color X, 2 in a row use color Y, 1 only use color Z.

    or

    1 Formula with 3 possible conditions...

    Mark

  13. #13
    Forum Expert
    Join Date
    01-15-2007
    Location
    Brisbane, Australia
    MS-Off Ver
    2007
    Posts
    6,591

    Re: Macro to identify a trend

    Hi

    using your example file from #10, remove the conditional formatting formulas, then try

    Please Login or Register  to view this content.
    Is this the sort of result you were looking for?


    rylo

  14. #14
    Registered User
    Join Date
    04-15-2013
    Location
    Sydney
    MS-Off Ver
    Excel 2003
    Posts
    9

    Re: Macro to identify a trend

    Rylo...

    I think we need to change your status from Guru to Legend.... It worked like a charm... Huge thankyou for your time and knowledge.

    Mark

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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