How to allocate rows to a list in excel - excel
I wanted to allocate the work to the number of people that can work on the task.
From the left table (raw data), I will input the names of the available workers. Then as a result, right table, the 5 people was then allocated 3 each. The work for each person is determined by the user, (much better if it will be automatically calculated to be allocated to each person equally, eg. 10 workloads to 5 people = 2 workload each, 100WL to 5P = 20WL each, and so on. hope you get the gist)
I am not familiar to excel, the processes and computations that it can do, but I am familiar to VB6 as it seems to be the backend coding of excel, so I will go down the coding path to execute this command. If possible, it will be greatly appreciated if one can provide me a sample in excel, so I can study, edit and tweak it a tad better as I am new(first time) to using VB6 in excel.
This formula will do what you need. Enter it in B2 and fill it down the column:
=INDEX(C:C,MOD(ROW()-2,COUNTA(C:C)-1)+2)
Breaking it down:
INDEX(C:C,[row]) -- Return the value at [row] in column C
Where [row] is:
MOD(ROW()-2,COUNTA(C:C)-1)+2
Breaking this down:
ROW()-2 -- Current row number in column B - offset to zero-base
COUNTA(C:C)-1 -- Number of workers in column C (-1 removes header)
MOD() -- Converts B row number into value in range [0 - # of Workers)
+2 -- Offsets [0-workers) to [2-workers+2) to account for positioning in col C
If you only want names to appear in column B if there's a task to perform, you can wrap the formula in an IF:
=IF(LEN(A2)>0,INDEX(C:C,MOD(ROW()-2,COUNTA(C:C)-1)+2),"")
Then you can fill this formula down hundreds of rows and names will get added automatically as you add work.
Related
Excel multilevel array formula with partial string matches to sum resultant cells
I've been trying to sort this for over a day now without much luck. I have successfully used SUMIFS, INDEX, MATCH, COUNTIF, "--" etc array functions previously and am not a novice, but also not an expert on these. I can't seem to weave these together correctly, and likely on an altogether incorrect path. Basically, I am trying to aggregate data from multiple spreadsheets, requiring a mapping of various items (rows) into a canonical form for summing. The image here shows a representative, but simplified version of my quest. Each "region" on this example spreadsheet (Final..., Mapping, DataSet1, DataSet2) is actually in different spreadsheets, and there are several sheets with 50-150 rows in each xlsx. Note that the names in Column B are quite arbitrary (meaning not all P1's have an 'x' pattern, like shown here as x1, x2, etc. Do not rely on any pattern in the names, except the x, y , z in the Mapping table are substrings (case insensitive, trailing match) of the names in Column B in the DataSets. And in the image, the Final Result Table (summed manually) is what I want to compute via(an array) formula: A single formula would be ideal (given I have many spreadsheets from which the monthly data is being pulled from, so I can't readily modify but can create an interim spreadsheet if required, so open to helper columns or helper rows). Here's the process - For each name (B3-B5) in the Final Result Table, I want to sum the name from it's components as follows: Lookup all the matches in the Mapping Table (so for P1, the formula =IF($C$10:$C$15=$B3, $B$10:$B$15,"") gives {"x1";"";"";"x2";"";"x3"}. I then want to search each of x1, x2, and x3 in B19:B26 to get rows 21, 22, 24, 25, 26 in DataSet1 and B31:B35 to get row 32 in DataSet2, to then add up the Jan totals into C3. (Effectively, C3=C21+C22+C24+C25+C26+C32). Same for P2 and P3, and thru Feb, Mar, ... I am stuck on how to remove blank or 0 or Div0 or such "error rows" from the interim result in 2, and also need to use 2 arrays of different sizes (3 valid rows in example 2 above, ignoring blanks) to search many rows in DataSets. I tried SEARCH("*"&IF($C$10:$C$15=$B3, $B$10:$B$15,""), $B$19:$B$26) but get unexpected results. I have tried to replace text in the interim result {"x1";"";"";"x2";"";"x3"} with TRUE/FALSE, and 1/0, etc. to help with INDEX or MATCH, but am stymied by errors in downstream ("surrounding") formulas. Thanks in advance.
Here is a solution without resorting to nasty (imo) CSE formulas. = SUMPRODUCT($C$19:$F$26*(COUNTIFS($B$10:$B$15, RIGHT($B$19:$B$26,2),$C$10:$C$15,$B3)>0)*($C$18:$F$18=C$2)) + SUMPRODUCT($C$31:$F$35*(COUNTIFS($B$10:$B$15, RIGHT($B$31:$B$35,2),$C$10:$C$15,$B3)>0)*($C$30:$F$30=C$2)) There is one SUMPRODUCT for each data set. If possible, it would be better to put all your data sets into a single table with a column identify which data set it is a part of. The way it works is to takes each values in your data set and multiplies it by whether the 2 right most character appear in your mapping table for that P code, multiplied by whether the value is in the correct month. So it returns 0 if either of those conditions are false. Then returns the sum. UPDATE IN RESPONSE TO OP COMMENTS If, the X,Y, Z codes are not always 2 digits but the first part is ALWAYS 8 digits, you can easily amend the: RIGHT($B$19:$B$26,2) to be: RIGHT($B$19:$B$26,LEN($B$19:$B$26)-8) Making the formula for the first data set: =SUMPRODUCT($C$19:$F$26*(COUNTIFS($B$10:$B$15, RIGHT($B$19:$B$26,LEN($B$19:$B$26)-8),$C$10:$C$15,$B3)>0)*($C$18:$F$18=C$2)) And you can amend for other data sets and simply add them together.
Nice challenge! Are you willing to drop all your tables (DataSet1, DataSet2...) into one spreadsheet, so that we can refer just one single range for each month? Here's one solution (hopefully a good starting point) - array formula (Ctrl+Shift+Enter): =SUMPRODUCT(IFERROR(IF(TRANSPOSE(IF($B3=$C$10:$C$15,$B$10:$B$15,""))=RIGHT($B$18:$B$36,2),C$18:C$36,0),0))
Create an Excel Formula that uses filtered data
I'm trying to design a second page that shows % results of my data on page 1. For example, Column F & G allow manual entry of numbers 1-4 which are based off data the user types in at another location. This is being used for trade tracking in investments so there will be quite a few numbers but the end result will be a row will show a specific stock, it's subsequent data, whether it made or lost money, etc. What I want to do in page 2 is using the numbers 1-4 which were typed in at columns F & G, translate that into an edge on page 2. For example, if there were 50 columns of data typed out for trades executed, I could take the number of winning trades of a certain setup (say number 3) and divide that by the total trades of 50 to come out with a win % for that setup. However, I have no clue to how to translate that forumla into a filter formula so that on page 2 I could see that of the numbers 1-4 (4 different setups) I could easily see the highest and lowest win % to determine the best setup to use. I'm not the best in excel but I understand enough to code most of that, I simply have no idea how to take that end formula and add a filter to it so that it only uses partial results. I've got 4 other formulas I want to use on page 2 as well to help build something that could really benefit myself, but if someone could just show me how to filter data into a formula, I think I could take it form there. Thanks for the help Ben
You can also do something like this with array formulas =MAX(IF(Sheet1!$F$2:$F$50=$A2,$E$2:$E$50)) (Press Ctrl+Shift+Enter [CSE], instead of just Enter when entering Array Formulas) Also, take a look a the SUMPRODUCT function. It comes in very handy for filtering data. Here are some helpful links... https://www.get-digital-help.com/2017/12/07/sumproduct-multiple-criteria/ https://www.get-digital-help.com/2017/12/08/sumproduct-and-if-function/ https://www.get-digital-help.com/2010/09/01/extract-a-unique-distinct-list-by-matching-items-that-meet-a-criterion-in-excel/
How to find the index of remaining columns if the data is repetitive
I have a data entry like thisData entries Now, i need to find the smallest 10 values and also get the corresponding person and area and date along with it. I used SMALL functoin to find the least 10 values. Then I used the index and match functions for getting their corresponding row entries. The problem is since some data entries are being repetitive, these functions are giving the row of the first 2 for all the remaining 2s. How to solve this
In F2 use Rank like this, so you have unique numbers: =RANK(C2,$C$2:$C$21,1)+ROW()/1000 in G2 use Small, to pull the smallest of the ranked numbers and copy down 10 rows. =SMALL($F$2:$F$21,ROW(A1)) Now you can pull person, date, real hours and area with an index match in H2, copied across and down. =INDEX(A$2:A$21,MATCH($G2,$F$2:$F$21,0))
Excel - find the biggest gap between numbers in rows
I have an excel file with >12500 rows in one column. It contains such random strings with 20 digits: 2,3,4,6,7,8,12,13,14,24,30,42,45,46,48,50,56,58,**59**,61 1,2,6,8,11,12,13,16,17,21,24,27,28,33,34,42,44,48,58,61 3,7,10,13,14,15,18,21,23,24,25,29,30,34,37,48,51,56,57,60 8,11,13,16,17,19,21,27,29,35,36,39,42,44,46,50,53,54,57,60 2,4,7,9,21,26,28,30,32,34,35,37,38,39,43,44,50,60,61,62 10,13,15,18,21,22,23,24,25,26,40,42,48,49,51,52,56,**59**,61,62 1,2,4,7,14,15,18,20,24,29,30,32,35,41,42,50,52,55,58,62 1,4,8,9,10,12,17,24,25,33,37,41,43,44,46,49,52,**59**,61,62 1,2,4,6,9,12,15,17,21,24,30,31,32,36,41,44,47,48,51,58 2,7,10,12,15,16,20,24,25,27,30,33,39,44,45,52,54,55,58,60 5,7,10,11,20,22,24,31,32,33,36,38,39,41,43,47,50,52,56,58 3,6,8,9,14,15,19,21,25,28,34,37,39,45,47,54,55,56,57,**59** 1,2,3,4,5,8,14,15,18,20,23,31,33,37,42,45,46,51,52,55 I need to know whats the biggest gap between rows where a number hasn't repeated. For example - I search for any number (e.g 59) and I need to know what's the largest gap between two rows where number 59 hasn't repeated. In this example it's 4 row gap between 59's. Hope that I make myself clear.
Seems like a fun problem which admits a simple but not quite obvious answer. First -- make sure that the data is in 20 columns (use the text to columns feature under the data tab). Using your example, I came up with a spreadsheet that looks like: V1 holds the target number. The formulas are in columns U. In U1 I entered: =IF(ISNA(MATCH($V$1,A1:T1,0)),1,0) This formula uses MATCH to test if the value in V1 lies in the range to the left of it. If it doesn't the match function returns #N/A. The function ISNA checks for this error value. IF it is present, the overall formula returns 1 (since there are now 1 consecutive row without the target number) otherwise it returns 0. The formula in U2 is similar with a little twist: =IF(ISNA(MATCH($V$1,A2:T2,0)),1+U1,0) The same basic logic -- but rather than returning 1 if the target number isn't present it adds 1 to the number above. The formula is then copied down the rest of the range. It has the effect of keeping a running total of consecutive rows without the target value. This running total is reset to 0 whenever a row with the target value is encountered. The final ingredient requires no comment. In U14 I just have =MAX(U1:U13) which is the number you are looking for (assuming that the maximum number of consecutive rows without the target number is what you are looking for, even if this occurs either at the top or bottom of the data. If you want the largest gap that is literally between two rows where the number occurs, the logic would need to be made more complex).
Break-Down Data in Excel without VBA (Formula Only)
Many times, I am required to provide some type of break-down to the customers - an example is shown in the attached figure. I have a table of data ("TABLE DATA" - which is some type of pivot) + Customer provides its official form, its structure must be preserved (highlighted in yellow ). Basically, I need to separate the cost details of CODE "A" and CODE "B" into 2 separated sections. Customer requires me to provided details for each individual Part (example shows Part A - "Break-Down Part A) Is there anyway to put a"ITEM" from "TABLE DATA" into Code A and Code B ? the rests can be solved by Vlookup (Price, Quantity) - note: "ITEM" is non-duplicated values . Thank you very much
Number your rows in the breakout using =1 and =A1+1 and then just use the formula ="B-ITEM"&TEXT(A1,"000"). If you want to skip making a counter column you could use ="B-ITEM"&TEXT(ROW()-1,"000") to just use the current row number (minus 1 or however many you need). If your items aren't sequentially like that, but still unique, I would recommend adding counters on the original tab similar to what you have, which would let you quickly find the 5th A or 7th B, something that counts the previous instances of your current type, and then adds 1. For Row 6 you could do =COUNTIF(A$1:A5,A6)+1.