Solved

Math in Macro needs fix

Posted on 2013-12-05
12
187 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 4
  • 3
12 Comments
 
LVL 48

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 48

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
SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

 

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 48

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 81

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
 

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 81

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 48

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 81

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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

How to get Spreadsheet Compare 2016 working with the 64 bit version of Office 2016
In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
This Micro Tutorial will demonstrate how to use a scrolling table in Microsoft Excel using the INDEX function.
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

626 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