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
505 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
  • 7
  • 5
  • 2
14 Comments
 
LVL 29

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 35

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
 

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 35

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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 29

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 29

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 29

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 29

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

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…
Freeze panes is an option within all variants of Excel to enable parts of a sheet to remain stationary when the cursor is in another part of the sheet. This is a very useful feature which is overlooked or under used.
The viewer will learn how to use the =DISCRINV command to create a discrete random variable, use this command to model a set of probabilities and outcomes in a Monte Carlo simulation, and learn how to find the standard deviation of a set of probabil…
The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…

929 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

15 Experts available now in Live!

Get 1:1 Help Now