I am thinking this is gonna be a simpler answer than I'm making it, but here goes nothing. I have a project I am working on using Excel and Python, where I am going to calculate the results for a season of NASCAR using the different points systems. I had tried doing this only using Python, but figured doing it in Excel first is better. The thing is, I have all the results for all 36 races inputted in Excel, with formatting for drivers who lead a lap, drivers who lead the most laps, and drivers not elligible for points.
How I have the formatting is as follows:
Inelligible driver's names are in red text.
Driver(s) who lead a lap are in bold text.
Driver(s) who lead the most laps are in bold text and bold border.
Driver(s) who had penalties have a red background.
Is there a way I could assign values based on these formatting conditions?
As for the penalties, those I could calculate separately if needed.
Please let me know whatever you may suggest.
Each column contains the results for a single race, and since there are always 43 drivers, the block of cells contains 43 rows (plus a heading row with each race name).
An option I'm thinking of is, to have the results for each race on Sheet1, then on Sheet2 have a list of all valid driver names, then copy and paste it twice, one for each option (2 bonus points, 1 bonus point, and no bonus points), and name each list. Also, I will have names for each driver, as well as names for each position. Then, when calculating the points after a race, use an if-then-else formula similar to the following:
IF A2 = driver_most_led [Driver_Name = Driver_Name + Position_Points + Most_Led_Bonus], ELSE IF A2 = driver_lead [Driver_Name = Driver_Name + Position_Points + Lead_Bonus], ELSE [Driver_Name = Driver_Name + Position_Points])
I know it's a long example, but not sure if this is legit or not.
Related
I am looking for some decent help with my matrix table, and is there a good or best approach to properly match dependent instances in certain matrix using drop downs.
This picture represents my matrix table (Picture 1):
As you can see there are a lot of instances, but horizontally and vertically they got the same number of "headers". Those "1`s" are representing not compatibility in my case but lets call it simply "match". That is on one sheet that is gonna be populated with some new values from time to time.
On another sheet which is actually sheet for showing the data and their compatibility possibilities is equipped with drop downs. There you got "Groups (Group1, Group2...)" in a sense of main parts and "dependent groups (AA1, BB2..)" as small components that are part of main parts. To avoid misunderstanding here you have explanations, I used for the sake of this example fictional values:
Groups aka. Main Parts
Dependent groups aka. components
As you can see beneath, is my fictional table but exactly the same concept as I should use in my real case.
I PUT AN EXPLANATION IN THE PICTURE 2 SO YOU CAN FOLLOW ALONG AND SEE EXACTLY WHERE/WHAT I DID!
What I used firstly there are =match functions, one for vertical position (A3) and one for horizontal (B4). This boolean row is done using =or(index) but reffering to the match positions as you can see. And from there I should use true/false for coloring my group boxes in a case compatibility is possible - thats all the science.
So, my question is if there is another approach to this problem? As you can see I have 3 different rows of functions at one place, or imagine if I will have more "groups" that can rise in many more rows and calculations.
Picture 2
EDITED:
This is screenshot of the original sheet, I just hid some rows that were with Infos that is reason the number is not consistent. As you can see it is almost the same as dummy example I provided above. Underneath every "box" you got three rows of calculations as I mentioned before. The two times number "2" that you see here is the position of some value that I found using =match function, one is for horizontal and another for vertical lookup. In this case it is model type, 070FX is position 2, 100FX is 3 and 200FX is 4th position in the matrix table, and so on for all the other groups. And those groups (Model, Endpoint, Gas sensor...) are defined separately on another sheet where I had to make unique list and dependent list so I can reference those to my drop down list.
EDIT Nr 4! So this formula I used for true/false:
=SUMPRODUCT(('0359-matrix'!$A$2:$A$101=F10)*(('0359-matrix'!$B$1:$CW$1=$B$10)+('0359-matrix'!$B$1:$CW$1=$C$10)+('0359-matrix'!$B$1:$CW$1=$D$10)+('0359-matrix'!$B$1:$CW$1=$E$10)+('0359-matrix'!$B$1:$CW$1=$F$10)+('0359-matrix'!$B$1:$CW$1=$G$10)+('0359-matrix'!$B$1:$CW$1=$H$10)+('0359-matrix'!$B$1:$CW$1=$I$10)+('0359-matrix'!$B$1:$CW$1=$J$10)+('0359-matrix'!$B$1:$CW$1=$K$10)+('0359-matrix'!$B$1:$CW$1=$L$10)+('0359-matrix'!$B$1:$CW$1=$M$10)+('0359-matrix'!$B$1:$CW$1=$N$10)+('0359-matrix'!$B$1:$CW$1=$O$10)+('0359-matrix'!$B$1:$CW$1=$P$10)+('0359-matrix'!$B$1:$CW$1=$Q$10)+('0359-matrix'!$B$1:$CW$1=F13)+('0359-matrix'!$B$1:$CW$1=G13)+('0359-matrix'!$B$1:$CW$1=H13)+('0359-matrix'!$B$1:$CW$1=I13)+('0359-matrix'!$B$1:$CW$1=J13))*'0359-matrix'!$B$2:$CW$101)>0
I copied only last part, or when it starts from second row..Because it is too long to write whole funciton - it cuts down automatically.
('0359-matrix'!$B$1:$CW$1=$Q$10)+('0359-matrix'!$B$1:$CW$1=$B$13)+('0359-matrix'!$B$1:$CW$1=$C$13)+('0359-matrix'!$B$1:$CW$1=$D$13)+('0359-matrix'!$B$1:$CW$1=$E$13)+('0359-matrix'!$B$1:$CW$1=$F$13))*'0359-matrix'!$B$2:$CW$101)>0
But on marked cells I am getting the same results: B22 - F22 has the same as B21 - F21 (boolean) what shouldnt be like that but to follow color, green is False, it has to be something with an array reference.
Checkout the following. A1 to E5 is the matrix that shows which pieces are incompatible (=1). The others have to be empty or 0.
In cell I8 I used the following formula (and copied it down up to I11):
=SUMPRODUCT(($A$2:$A$5=H8)*(($B$1:$E$1=$H$8)+($B$1:$E$1=$H$9)+($B$1:$E$1=$H$10)+($B$1:$E$1=$H$11))*$B$2:$E$5)
The formula result shows you the amount of incompatibilities a part has. Eg AA1 has one incompatibility with BB2 but BB2 is incompatible with 2 AA1 and CC3.
To get the TRUE/FALSE use the same formula and append >0: like =SUMPRODUCT(…)>0
For any additinonal "group" (Model, Endpoint, …) you need to add another +($B$1:$E$1=$H$12) where $B$1:$E$1 points to your matrix data and $H$12 to your selected group value.
Overview of the formula ranges:
Note that this kind of calculation can only tell the amount of incompatibilites a part has but not the names of the parts that are incompatible.
Edited horizontal version
Formula in the selected cell is
=SUMPRODUCT(($A$2:$A$5=G8)*(($B$1:$E$1=$G$8)+($B$1:$E$1=$H$8)+($B$1:$E$1=$I$8)+($B$1:$E$1=$J$8))*$B$2:$E$5)
you can pull it to the right.
I am working in woodworking industry. I want to speed up my workflow using reusable worksheets in excel. I am making material quotation, summerazing all the stuff what we need to build the cabinets. These cabinets usually custom cabinets, I have to write all the sizes, quantities etc by my hand, after I done I must summarize the data to make a price offer. I did a script in Blender python, works fine, but I need to do it in Excel worksheets aswell. My problem:
I write down the sizes for a board (which has 4 sides).
No problem to get the square meters I just simply multiply the numbers. But I have a cell called "Edgebanding". We use two types of it: 1 is called PVC (small letters) 2 is called ABS (capital letters). To summarize these I need a code (I am coding like 8 years now). I just simply write down the code what I need:
SUMPVC = 0
for length of string(Edgebanding cell) with each letter
if currentLetter='a' then
SUMPVC+=BoardWidth(B Cell value)
elif currentLetter='b'
SUMPVC+=BoardHeight(D Cell value)
end for cycle
return width SUMPVC*Quantity(F cell value)
SUMABS = 0
for length of string(Edgebanding cell) with each letter
if currentLetter='A' then
SUMABS+=BoardWidth(B Cell value)
elif currentLetter='B'
SUMABS+=BoardHeight(D Cell value)
end for cycle
return width SUMABS*Quantity(F cell value)
Is it possible (and if so..how?) to make this as a function like the other operators in excel (like "=SUM(range)".
So it seems like "=SUMPVC(E2)" and "=SUMABS(E2)
I attach a screenshot, just to be clear what I am talking about.
Thanks in advance! Alex
Example
I do not have 50+ reputation, so I cannot post this as a comment:
In the link above, there is a small tutorial on how to create a formula. Just adapt to your need.
http://www.dummies.com/software/microsoft-office/excel/how-to-create-custom-excel-functions/
I basically have three tables that I want to test through an IF/ else IF formula in Excel. The first table corresponds to whether I would take a bet given a set of parameters (in short, this is a n row x 1 column table filled with 1s and 0s). The second table is whether I would win the bet (this is also nx1 and filled with 1s and 0s). The third column is the profit I would make if I did take the bet AND if I won.
So far the pseudo-code I have is:
if (would bet=1) AND (would win=1), are...
TRUE: display profits
FALSE: if (would bet=1) and (would win = 0) are...
TRUE: -1 (for losing $1 betting)
FALSE: 0 (for not betting)
I have my tables set up as follows:
Profits table: column A
Would bet table: Column B
Would win table: Column C
so in cell D1, I entered:
=IF(AND(B1=1, C1=1), A1, IF(AND(B1=1, C1=0), -1, 0))
but for some reason, I'm not getting any -1's though there are supposed to be some.
Can anyone help?
Thanks.
I think you can simplify your logic a bit to the following pseudo code:
IF (would bet)
IF (would win)
DISPLAY PROFITS
ELSE
DISPLAY -1 // loser!
ELSE
DISPLAY 0 // didn't play
With that simplified logic, I think you can go with this as your formula:
=IF(B1=1, IF(C1=1, A1, -1), 0)
Where B1 = would bet, C1 = would win, A1 = profits
As a small aside/contribution, this is a fairly short formula, but I often split complex IFs in several columns to do the debugging easier , or, for really complex (or maybe overcomplicated :)) decisions I create a custom formula and code the logic as in your pseudocode pretty much. that has a performance penalty in big tables and requires saving it as a macro enabled xlsm which requires users to enable the content, but it improves auditability massively, reduces the risk of error and let to comment the code for the future. I would recommend (if not yet familiar) that you give it a go to have another tool in your belt. You can google around on how to create a custom formula)
Cheers
I need to compare two columns and find out what is missing in one of them.
Color available color required color missing
Blue, red (blue,white) or (blue,green)
White (green) or (red)
Blue,white,green (blue,white,pink) or (x,y,z)
I have a list of around 300 rows that I need to work on on a daily basis, which is very time consuming.
Can someone please help me get this information under column color missing?
This is not the type of question that will get answered here. Firstly, you are very unclear what you seek. Secondly, I suspect you will need a lot of code to achieve your objective.
Stack Overflow is for programmers seeking help to improve their code. It is not a free-coding site.
This is my guess of your requirement
Color available color required color missing
Blue, red (blue,white) or (blue,green) (white) or (green)
White (green) or (red) (green) or (red)
Blue,white,green (blue,white,pink) or (x,y,z) pink or (x and y and z)
As far as I know Stack Exchange, the parent site, does not have a site for help with designing programs which I believe is what you need.
You must first design your program. What tasks must be performed to achieve your objective? You then need to attempt to program each of those tasks in VBA. If you fail at a particular task, post your faulty code here with an explanation of its objective. If a task is small and you do not have a clue where to start, a question here might be answered.
First question for you: how much VBA do you know? There seems to be a belief that you can scan the internet for bits of VBA script and stitch then together into working program with minimal knowledge of VBA. I do not share this belief. I have tried searching the internet for answers to what I think are simple questions. I have found answers that I know include the required code but I cannot see how you could extract that code from the noise without VBA knowledge. You can search the internet for "Excel VBA Tutoral" or you can find a book in a good library or bookshop. Spend some time getting a basic understanding of VBA. That investment in time will repay itself quickly.
Below is my attempt at an initial list of tasks.
You imply the number of rows varies from day to day. You need to discover the last used row today. You need to know how to address a particular worksheet cell so you can access its value. You can access worksheet cells directly but it is faster and usually more convenient to copy the worksheet to an array. This is all basic worksheet access information.
In column 1, you have colours (some with capital letters) separated by comma or comma space. To process these colours you need then in an array:
Avail(0) = blue, Avail(1) = red
Avail(0) = white
Avail(0) = blue, Avail(1) = white, Avail(2) = green
The function Split will split strings like these into an array containing the values I have shown: Avail = Split(Col1Value, ",") Function Trim will remove leading and trailing spaces. Function LCase will convert upper case characters to lower case.
Column 2 is more complicated. In all your examples, you have a single " or " and the colour groups are surrounded by brackets. Can there be more than one " or "? Are the groups always surrounded by brackets? Could the spaces around the "or" be omitted so an example could be: (red, green)or(blue,white) or (red, green)or (blue,white)?
If the values in column 2 are inconsistent, I suspect the easiest solution is to make them consistent. For example:
Col2Value = Replace(Col2Value, ")or(", ") or (")
Col2Value = Replace(Col2Value, ") or(", ") or (")
Col2Value = Replace(Col2Value, ")or (", ") or (")
You could then use Split: Alternative = Split(Col2Value, " or ") to give:
Alternative(0) = (blue,white)
Alternative(1) = (blue,green)
For each alternative, you need to trim any spaces, remove the leading and closing brackets and split it like the Col1Value. You now have two arrays and you can search the second for values missing from the first and build a list of missing colours.
I hope this is enough for you to understand what I believe you must do. I have split the total program into small tasks. Gaining access to the worksheet. Splitting column 1 values into separate colours. Making column 2 values consistent if necessary. Splitting Column 2 values into alternatives. Splitting alternatives into required colours. Each of these is a straightforward task which you should be able to solve with relatively simple VBA.
Good luck.
My apologies if this has already been answered in some form; it’s difficult to come up with the correct wording to do a proper search.
I have been charged with creating some basic reporting for my team and I need to create an “if-then” formula. Essentially, if Column A contains the word “Open Rate,” I want the formula to grab the associated percentage from column B (16.49%) and make an average of all the open rates on another sheet. (16.49% + 14.98% + 14.48% / 3 = 15.31%)
I would simply add all of them but the data set is ridiculously large and always growing. Also, the numbers of rows between data sets are not equal and thus a nice pattern is out of the question.
excel uses a vb type syntax
=IF(A2<>"open rate",A2,AVERAGE(Sheet2!A:A))
the above formula says if a2 is not equal to open rate, then return a2, else return the average of column A in sheet 2
Please try:
=AVERAGEIF(Sheet1!A:A,"=Open Rate",Sheet1!B:B)
with your first sheet name adjusted to suit, if necessary.
Edit re supplementary
Google Doc does not at the moment have a function =AVERAGEIF, however it does have the building blocks for it. Average (as in arithmetic mean) may be calculated as the sum of the values in a dataset divided by the count of all the individual items in the dataset:
=sumIF(Sheet1!A:A;"=Open Rate";Sheet1!B:B)/countIF(Sheet1!A:A;"=Open Rate")
Google Doc does have the =AVERAGE function and this may be more suitable than the above.