Solved

Macro for Excel 2011 on MAC - discover interaction, look into matrix for value and translate impact into a given range of cells

Posted on 2014-01-10
14
520 Views
Last Modified: 2014-01-11
Hi Experts,

since I already know how powerful your brains are I would like to kindly ask you for extra help with building a macro to help me to run a specific evaluation of interactions btw different categories (in this case A - I).

Here, I also include the WB where I need to make this happen:

WorkbookSample-MAC.xlsm

What I need the macro to do is the following:

I have an input table that looks like this:

input-table.tiff

I want to use the checkboxes to do the following for me:

when unchecked - the effect of relevant category will be 0

when checked - the macro will scan the array with checkboxes (in my case column Q) and will search for other checked boxes. Two possibilities may appear:

1) there are no other checked categories and the intensity of the category effect will remain full

2) there are other checked boxes and the macro will look into a predefined matrix (in my case sheet InteractionMatrix) and will look if there is an interaction between the box I checked and other checked boxes / categories within the array.

2.1) if there is no interaction (represented by value 0) - intensity remains unchanged
2.2) if there is an interaction (represented by value 1) - intensity will be adjusted according to relevant values that the macro will search for in matrix in sheet ValueMatrix) - multiplier will be shown in the sheet Summary (2) column P (attributed to relevant category).

I think it's a lot of if statements combined together essentially that need to be coded.

The hard part is that the interaction effect should translate also to the category with which our "checked" category interacts - say A interacts with B - and if B is checked it should assume for the same interaction value.

This may be still easy to do BUT we know there are multiple interactions between the categories and so if I have checked A, B, E and they all interact - the effect should be recorded in the column P for all of them.

The interaction functionality may be attributed to a command button - however would be nice if could be automatic - whatever is easier though in terms of sequences of calculations.

I hope this post is clear and the goal with it.

I appreciate your help of any kind!

I hope we get this riddle solved!

Thank you in advance.

J.
0
Comment
Question by:le_johney
[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
  • 7
  • 5
  • 2
14 Comments
 
LVL 31

Expert Comment

by:gowflow
ID: 39772434
Sorry but ot at all clear it is like trying to find a needle in the land of nowhere that is located in taboulistan that is the sub continent of the pursian Asian left of the west coast of nowhere !!

If you understood something of what I wrote, then you are better off with my understanding of what you want to achieve !!!

Second, having worked on this file, I do not see the essential macro that was developed already un der Record button which again leave me more lost !

gowflow
0
 

Author Comment

by:le_johney
ID: 39772461
Hi GowFlow,

this is just an add on to the work we have already done - didn't want to link whatever I am trying to do now to what we'd done previously.

OK, I will try to be more clear about this:

Essentially I have a column Q with checkboxes.

I need to find a way how to make the checkboxes interact - if A is checked (TRUE) and I also check B (TRUE) the macro will look into the matrix in the sheet InteractionMatrix to look if these categories A and B are related. If they are related (value 1 from the matrix), the macro will go search for their correlation in the matrix in sheet ValueMatrix.

Then if I check also box for category D, the macro will need to evaluate the correlation of D with A and D with B (and possibly every other categories that will be checked later) to come up with a) whether they are related, b) if they are what is the value of correlation from the ValueMatrix sheet.

Now what the macro does afterwards is that it multiplies the correlations (if they exist and puts the value in a relevant cell (right next to each category) in column P).

Again, in real world talk - category A stand alone performs on 100% but if it is correlated with B and I select B to add it to the portfolio, it will decrease the effect of A by a certain factor and make A less efficient in that mix.

I hope this helps.

I know it may sound simple to me but pls. do let me know if you are still lost in that taboulistan :)

Thanks

J.
0
 
LVL 36

Expert Comment

by:Kimputer
ID: 39772476
sample code, you can finish yourself. This is code only for step 1 and checkbox A (assign the macro there):

Sub CheckBox2_Click()

'checkbox A code

'checking checkbox B
If LCase(ActiveWorkbook.Sheets(1).Cells(62, 2).Value) = "true" Then
    MsgBox "b is checked"
    If ActiveWorkbook.Sheets(2).Cells(3, 3).Value = "1" Then
        MsgBox "matrix = 1"
        'add more interaction value code
    End If
End If

'checking checkbox C
If LCase(ActiveWorkbook.Sheets(1).Cells(63, 2).Value) = "true" Then
    MsgBox "c is checked"
    If ActiveWorkbook.Sheets(2).Cells(3, 4).Value = "1" Then
        MsgBox "matrix = 1"
        'add more interaction value code
    End If
End If

'checking other checkboxes etc etc totalling 8 statements

End Sub

Open in new window


if you look through the code I think you can first finish the code (and matrix values), and then slightly adjust it for all checkboxes (copy & paste for each checkboxes, then make minute changes, making a total of 9 subs, each with 8 if statements)
After you're done, we can start with the other points.
0
Veeam gives away 10 full conference passes

Veeam is a VMworld 2017 US & Europe Platinum Sponsor. Enter the raffle to get the full conference pass. Pass includes the admission to all general and breakout sessions, VMware Hands-On Labs, Solutions Exchange, exclusive giveaways and the great VMworld Customer Appreciation Part

 

Author Comment

by:le_johney
ID: 39772492
Thank you very much! Will definitely try this.

Although this seems to be a little long for what VBA can really do. Is there a way to go around this and make it shorter? String type maybe?

Thanks

J.
0
 

Author Comment

by:le_johney
ID: 39772519
...this is only supposed to show me that they are related right?
0
 

Author Comment

by:le_johney
ID: 39772526
is there a way to work with the range of the matrix instead of particular cell positions?
0
 
LVL 36

Expert Comment

by:Kimputer
ID: 39772571
Yes, you can have each checkbox have this code

Sub CheckboxA_click()

Clicked(1)

End Sub

Open in new window


checkboxb will have Clicked(2) etc.

the Clicked code would look like this:
Sub clicked(clicked_val As Integer)

For i = 1 To 9

If Not (i = clicked_val) Then
    a = 60 + i
    If LCase(ActiveWorkbook.Sheets(1).Cells(a, 2).Value) = "true" Then
        b = 2 + clicked_val
        If ActiveWorkbook.Sheets(2).Cells(b, 1 + i).Value = "1" Then 'this is your matrix!!!
            MsgBox i & "matrix = 1"
               'more interaction value code
        End If
    End If
End If

Next



End Sub

Open in new window

0
 
LVL 31

Accepted Solution

by:
gowflow earned 500 total points
ID: 39772639
Is this what you want ?

pls try it firs ton PC !!! :( then will worry about mac lets see if logic and calculation correct.
gowflow
WorkbookSample-MAC.xlsm
0
 

Author Comment

by:le_johney
ID: 39772665
Spot on GowFlow!!!!

You really are a Genius....Mastermind!

Thanks so much for this. It does just what I wanted it to do!

Have a great weekend and thanks for staying up late!

All the best!

J.
0
 
LVL 31

Expert Comment

by:gowflow
ID: 39772672
Your welcome my pleasure. Did you try it on MAC ?
gowflow
0
 

Author Comment

by:le_johney
ID: 39772687
I haven't,but I read the code and it seems like it will need the same work as last time - worksheet labeling/naming.

Again,thank you very very much!
0
 
LVL 31

Expert Comment

by:gowflow
ID: 39772738
ok so if the question is done for you and no help needed I would appreciate you close it as you feel appropriate. Meantime pls feel free to post here any link to any question you may need help with,
gowflow
0
 

Author Closing Comment

by:le_johney
ID: 39772841
GowFlow did it for me again! Good job!
0
 
LVL 31

Expert Comment

by:gowflow
ID: 39773024
My pleasure will keep this question monitored in case you need help down the line pls post a link in here will be glad to assist.
Rgds/gowflow
0

Featured Post

MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

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
You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
This Micro Tutorial demonstrate the bugs in Microsoft Excel for Mac with Pivot Charts.
This Micro Tutorial will demonstrate on a Mac how to change the sort order for chart legend values and decrpyt the intimidating chart menu.

630 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