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
499 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
...this is only supposed to show me that they are related right?
0
 

Author Comment

by:le_johney
Comment Utility
is there a way to work with the range of the matrix instead of particular cell positions?
0
 
LVL 35

Expert Comment

by:Kimputer
Comment Utility
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
Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

 
LVL 29

Accepted Solution

by:
gowflow earned 500 total points
Comment Utility
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
Comment Utility
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
Comment Utility
Your welcome my pleasure. Did you try it on MAC ?
gowflow
0
 

Author Comment

by:le_johney
Comment Utility
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
Comment Utility
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
Comment Utility
GowFlow did it for me again! Good job!
0
 
LVL 29

Expert Comment

by:gowflow
Comment Utility
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

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Convert between Excel file formats (.XLS, .XLSX, .XLSM) with/without macro option David Miller (dlmille) Intro Over this past Fall, I've had the opportunity to see several similar requests and have developed a couple related solutions associateā€¦
This article will guide you to convert a grid from a picture into Excel format using Microsoft OneNote and no other 3rd party application.
The viewer will learn how to use a discrete random variable to simulate the return on an investment over a period of years, create a Monte Carlo simulation using the discrete random variable, and create a graph to represent the possible returns overā€¦
This Micro Tutorial will demonstrate how to create pivot charts out of a data set. I also added a drop-down menu which allows to choose from different categories in the data set and the chart will automatically update.

771 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

11 Experts available now in Live!

Get 1:1 Help Now