Solved

Math in Macro needs fix

Posted on 2013-12-05
12
180 Views
Last Modified: 2013-12-08
EE Pros,

I have a Risk/Return Macro and chart that when you put two variables into each cell in a row, it plots the appropriate point on the grid.  Here's the issue.  When you prioritize the list, (it sorts the descriptions, it doesn't properly calculate the sort.  In other words a Return of 8 and a Risk factor of 4 should take priority over a Return of 9 and a Risk factor of 6.

Look at the WS to see what I'm trying to accomplish.

Thank you in advance.

B.
Math-in-Macro-is-incorrect.xlsm
0
Comment
Question by:Bright01
  • 5
  • 4
  • 3
12 Comments
 
LVL 45

Expert Comment

by:Martin Liss
ID: 39699339
When I click the button nothing happens perhaps because I'm missing some links. What happens when you click the button and what should happen if it were working correctly.
0
 

Author Comment

by:Bright01
ID: 39699582
Marty,

Thanks for taking a look......  Change the values in col. C and D and then hit prioritize.  It will then stack rank the text in the order of priority.  The problem I have is that it seems to prioritize the first value but it doesn't seem to properly rank the other values.  A 5 on Return with a 5 on Risk should be higher up then a 5 on Return with a 6 on Risk.

Make sense?

B.
0
 
LVL 45

Expert Comment

by:Martin Liss
ID: 39699612
That formula is too complex for me to analyze but if you can describe the formula's logic in words, perhaps I can come up with a VBA solution.
0
 

Author Comment

by:Bright01
ID: 39699658
Much thanks.

So, I think the best way to look at this is that there are two axis's that scale in opposite directions.  What happens is that a description is put into Column B.  Then a Return value and a Risk value are placed into Columns C (Return) and Column D (Risk).  The higher the number (1-10) in the Return axis, the more value.  The lower the number (1-10) in the Risk axis (D), the more value.  So the most valuable combination would be 10 (C) and 1(D) while the lowest value would be a 1(C) and a 10(D).  With that as potentially an array, every combined value should be able to be prioritized (and reordered in Column B.  

You will see that the model actually works well.....EXCEPT for the fact that the math doesn't completely work.  In the example I sent you, the order should be B, C and A when the Prioritize macro is fired.

Make sense?

B.
0
 
LVL 45

Expert Comment

by:Martin Liss
ID: 39699689
If this isn't correct please tell me where the 1, 2 and 3 should go.
What's wrong?
0
 
LVL 80

Expert Comment

by:byundt
ID: 39699785
Your "ranking" formula in column E is favoring higher risk rather than lower risk because you are adding the value in D7:
=(C7*2)+D7

If you subtract the value in D7, then the formula will favor lower risk over higher risk:
=(C7*2)-D7
0
Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

 

Author Comment

by:Bright01
ID: 39700754
Marty,

1 and 2 should be switched as they are prioritized.  1 has more value because while the return is =, the risk is lower. When that is determined, the graphic should show "1" as the best option and also have sorted the description and values in the table.

Make sense?

B.
0
 
LVL 80

Assisted Solution

by:byundt
byundt earned 250 total points
ID: 39700776
Bright01,
Did you try changing the formulas in column E as suggested? Your existing macro will work if you do that.

Brad
0
 
LVL 45

Accepted Solution

by:
Martin Liss earned 250 total points
ID: 39701077
1 has more value because while the return is =, the risk is lower.
Priority 2 has less risk (5) then Priority 1 (6), so shouldn't 2 be first?
0
 

Author Closing Comment

by:Bright01
ID: 39701961
Brad and Marty,

Thanks guys!  Based on the input you gave me, I was able to figure it out on my own!  

Here's what I ended up doing.  It was a long time ago that this graphic was made so I had missed the fact that I had a row hidden.  By unhiding the "helper" row, I changed the formula to =if(b="",0,(c + (10-d))) and it works perfectly when "priority" is fired.

Thanks again,

B.
0
 
LVL 80

Expert Comment

by:byundt
ID: 39701982
The original formula in column E weighted the Return twice as much as the Risk. Your revised formula assigns equal weighting to Return and Risk. Was this change in philosophy intentional?

From a ranking point of view, it doesn't matter whether you add the 10 or not. Even though the following two formulas return different results, they will make your rows sort exactly the same:
 =IF(b="",0,c + (10-d))
 =IF(b="",0,c-d)

The value returned by the first formula (on rows with data) will always be exactly 10 higher than the value returned by the second formula. This constant difference is why either formula can be used to rank your data for a sort.

Brad
0
 

Author Comment

by:Bright01
ID: 39705005
Brad,

Great comments!  I did want, in this instance, Risk and Return to be =.  Graphic looks pretty good now.

Thanks again,

b.
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

INDEX and MATCH can be used to great effect to replace HLOOKUP and VLOOKUP as it does not have the limitation of needing the data to be sorted so that the reference value is in the first column or row. It also has the ability to perform a bi-directi…
This code takes an Excel list of URL’s and adds a header titled “URL List”. It then searches through all URL’s in column “A”, looking for duplicates. When a duplicate is found, it is moved to the top of the list. The duplicate URL’s are then highlig…
Viewers will learn the basics of slicers and timelines for both PivotTables and standard Excel tables in Excel 2013.
The viewer will learn how to simulate a series of sales calls dependent on a single skill level and learn how to simulate a series of sales calls dependent on two skill levels. Simulating Independent Sales Calls: Enter .75 into cell C2 – “skill leve…

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now