i have an excel sheet in which the first few columns contain titles and information and the rest are repetitive 3 columns sets (i'll refer to as col1,col2,col3), containing dates.
i added an other 3 columns set in which i want to show the last date set in that row(i'll refer to as last1,last2,last3).
currently i set "last3" to look for the last non blank cell in row, last2 to look for the one before and last1 2 before.
problem is, not every time i fill the information i fill the whole set, meaning i could have a situation where the set contains col1 col2 values but not col3, then last3 actually takes a col2 value and messes up everything.
is there a way (please please no VBA programming) to write an array function of some sort that looks for the last 3 col set containing any value, and copying it to the last col set?
thanks!!
I have cooked up this formula for you. It isn't pretty and it's volatile (meaning, it will slow down your worksheet if you have a large quantity of these formula in it) but it does the job. It's the same formula for all columns and all rows.
=INDEX(INDIRECT(ADDRESS(ROW(),1)&":"&ADDRESS(ROW(),COLUMN()-1)),,COUNTA(INDIRECT(ADDRESS(ROW(),4)&":"&ADDRESS(ROW(),COLUMN()-1)))-MOD(COUNTA(INDIRECT(ADDRESS(ROW(),4)&":"&ADDRESS(ROW(),COLUMN()-1))),3)-(2-MOD(COLUMN()-4,3))+(4-1))
In this formula the number 4 stands for the first column of the first set of 3. If you have more columns to the left or fewer, change this number wherever you find it.
The number 3 stands for sets of 3 columns. the "2" in 2-MOD(COLUMN()-4,3)) is also related to this number being used here to reverse the result of Mod(,3) which will be 1, 2 or 0.
-1 generally stands for an adjustment, for example COLUMN()-1 is the number of the column to the left of where the formula resides. But in ADDRESS(ROW(),1) the "1" specifies column A.
The formula specifies a range starting from column 4 to the last column to the left of the formula and counts the number of entries in it, excluding cells of its own group. The 3 entries to be retrieved are in the range extending from itself 2 cells to the left.
If you deploy this formula, replace it with hard values when you add the same formula to the right of columns where it is already deployed. Use Copy/Paste Values (after copying the formulas to the right. This is to reduce the load on your worksheet.
BTW, I took a hard look at this thread, where they deal with columns. Some of the solutions there can be reformulated to work on rows but I failed to make them work on sets of 3.
Related
I have a problem where i need to sum two columns for a range of values in Column A and then output the result in a specific cell. i.e. Add Columns B & C together for Phase 1 then do the same for Phase 2 etc. The attached file shows what i need. Sample of what i am trying to achieve
I can use a simple formula to sum the content of of the two columns into the output cell for a selected range but what i really need is to be able to do this automatically when the number of rows in each range changes
Well you only have one IF so SUMIFS is not required (Will save processing power):
=SUMIF(A:A,F4,B:B)+SUMIF(A:A,F4,C:C)
Then ensure to check Formula Tab - Calculate Options - Automatic
So I'm going to eventually have 3 sheets. Sheet 1 is where I have data (numbers for a category and a name associated with it. Sheet 2 is where I pull the top 5 users for each category. Sheet 3 is where I have a leaderboard for points gained.
Right now I'm trying to work with Sheet 2 (grab the top 5 performers from each category. I'm fairly new to Excel, but after some research it seemed that XLOOKUP would be the way to go. (i'll attach screenshots below.
I'm using this formula:
=XLOOKUP(LARGE('Cases Test for Categories'!$C$18:$C$55,1),'Cases Test for Categories'!$C$18:$C$55,'Cases Test for Categories'!$A$18:$A$55)
however when using it I get all 0's.
Here's a screenshot of values I'm trying to grab from "Warranty Service Request"
and here is a screenshot when applying my formula
The solution I would want is to grab the 5 largest numbers from sheet 1 with the person name as well.
I don't think that XLOOKUP can get you anywhere near what you want but the formula below will get you one step closer.
=INDEX(List,MATCH(LARGE(INDEX(List, ,2),1),INDEX(List,,2),0),1)
In fact, it's the explanation of that formula which will be of help. Here we go.
List is a named range, perhaps equal to your 'Cases Test for Categories'!$C$18:$C$55. The reason for using a name is obvious. It's shorter. In my test List = A2:B6, in case you want to reconstruct it. Column 1 has names, column 2 numbers.
The term INDEX(List,,2) specifies the second column of List. You can replace the '2' with a formula to specify different columns of the named range.
In fact, INDEX(List,,1) does specify the first column and INDEX(List,4,1) specifies the 4th cell in that column, and that is exactly what you see in my formula. All of MATCH(LARGE(INDEX(List, ,2),1),INDEX(List,,2),0) just serves to find the row number in List, in this example the number 4.
Of course, LARGE(INDEX(List, ,2),1) returns the largest number in column2 of List. The '1' can be replaced by a formula, for example ROW()-1 which would return 1 if placed in row 2 and count up from there as it's copied down. Try =ROW()-1 in any cell in row 2 and copy the formula down.
MATCH([LARGEST],INDEX(List,,2),0) returns the row number where the largest was found, and that is the number we need to return the name from the first column of List.
This will work perfectly for one column and can easily be modified to work for different columns. Your question doesn't specify how you would like to arrange the 5 results from each category but the formula can be modified a little to accommodate whatever you want. What it can not do is to deal with ties. MATCH(LARGE can only find the first of several identical results.
To break ties in this sort of operation is complicated and must be done ether by helper columns in the data table or using VBA. It's definitely the topic of another question. For now I hope that it's a problem you will not have to anticipate.
I have the following formula:
=INDEX(TODAY!$D$2:TODAY!$D$306; MATCH(0; COUNTIF($A$2:$A2; TODAY!$D$2:TODAY!$D$306);0))
in the above example 306 is the number of ROWS in D column of the TODAY sheet that I get from the following formula:
=COUNTA(TODAY!D2:TODAY!D2000)
I can't figure out how to merge these two formulas together, so that in A column I get unique values for number of rows generated by second formula. Because if I copy the first formula along the A column it starts repeating from the beginning same values.
For example, what happens now is if I have 5 unique records in TODAY sheet but i copy the formula in 10 rows of A column it repeats those 5 records again. But I need to get only 5 records, others must remain blank.
Thank you!
One approach is to use OFFSET.
Here's a list of animals and we want to count horses and the list can grow but it's fixed on A2:A12.
To make it dynamic use OFFSET and your COUNTA formula e.g.
OFFSET(A2,0,0,COUNTA(A2:A40))
Which replaces the fixed A2:A12 range in the example.
thank you for taking a minute to help me!
I have 3 sheets, 3 of them with daily data of users, vehicles, and population which is steady, all of them have the same structure:
D column is location and the rest are daily results. Results change every 14 days, that's why for each location you are seeing the same data.
And there's a 4th, where I want to concentrate results from the previous sheets based on data and location - location is D column:
I want to set both start and end date and based on that, sum daily results by location. For example, suppose that Inicio - Start date is 01/03/2020 and Termino - End Date is 05/03/2020, in the second image, where I highlight SUM HERE it should appear 227,340 for 001-L1 Dr. Galvez N.
I already tried SUMIF, SUMIFS, SUMPRODUCT but it doesn´t seem to work.
Any ideas?
What didn't work with SUMPRODUCT? Try this - the result is correct:
=SUMPRODUCT((Sheet1!$E$3:$M$3>=$E$2)*(Sheet1!$E$3:$M$3<=$F$2)*(Sheet1!$D$2:$D$14=D5)*Sheet1!$E$4:$M$14)
I tried to adjust the ranges to your example, but change them if necessary.
I have developed this formula for you (001). Please take a look.
[E5] =SUMIFS(INDEX(Counts1,MATCH($D5,Stops1,0),0),Dates1,">=" & $E$2,Dates1,"<=" & $F$2)
The formula is designed for cell E5 of your fourth sheet. $D5, $E$2 and $F$2 are all on this sheet.
Counts1 is a named range on Sheet1, comprising all the passenger counts, starting from column E, up to the last day of the month and, vertically, from row 4 to as many rows as there are stations.
Stops1 is another named range on Sheet1 D4:[end of column].
Dates1 is a third named range on Sheet1, starting from E2:[end of row]. I would suggest you set up these named ranges to adjust dynamically to the actually used areas of the sheet.
Now, INDEX(Counts,MATCH($D5,Stops,0),0) defines all cells in the row of Counts where the Stop is equal to D5. Of course, this reference changes as you copy the formula down.
SUMIFS takes that range, extracts and sums up the numbers you are interested in.
Now, if you need to extract the same numbers by the same system from 3 different sheets you simply repeat the formula 3 times, concatenating the results with plus signs. That leaves you with the task to set up 9 ranges instead of only 3, each group of 3 on one of your source sheets. By the system I have implied above you would name them Count2, Count3 etc.
That leaves the question of your dates. They must be true dates. Text strings that look like dates won't do. (I guess you know that :-). In the test sheet I set up I entered =DATE(2020,3,1) in E2, [F2]=E2+1 and copied from F2 to the right.
I'm fairly new to coding and i've been googling around for the last few hours trying to solve this problem but it seems to be a little beyond what i'm able to do so i would be very grateful for some help
In Sheet1, I have a table which has columns between M - CV (175 columbs). For each column, i have an "ID number" value in row 3. From Row 6 to the end of the table, i have several "search terms" separated by commas in the column CV
In Sheet2, the corresponding "ID Numbers" are in column B. Column AN contains strings.
For each ID Number value in sheet1, i'm looking to find find all the corresponding cells in sheet2 where the ID number in Column B is the same, and Column AN of sheet2 contains at least one of the "search terms" in column CV
For each ID number, i'm hoping to join the entries in Column AN of sheet2 which match the criteria above and paste them into Row 5 of the respective column in Sheet1
I've gone around in quite a few circles trying to do this and i'm back to square 1 with no code to show for it.
I've tried to research both the autofilter function, and using for loops. The research i've done indicates that for loops are rather slow to run for a large data set.
I'm hoping to find a solution which is as easy to read and understand as possible
I hope i've given enough information for everyone to understand and help
THank you in advance
My Excel subscription has expired an I've started using Google Sheets for most of my spreadsheet work, so I tested this there. Some conversion may be required. I did this using formulas, not VBA also, not sure if that changes things for you.
If I understand correctly, you have two sheets with a shared key column, sheet 1 contains search terms across multiple columns, and sheet 2 contains search terms comma delimited in a single column.
With this setup we want to bring the search term column of sheet 2 into the correct row of sheet 1 by key using VLOOKUP. I made a named range in sheets which contained all my data on sheet 2 and called it "dst". My formula was then =VLOOKUP(A2, dst, 7, true) since my key in sheet 1 was in column A, dst was the range I was searching, my column with my delimited search terms was column 7 in relation to dst, and I had ordered sheet 2 by key. I pasted this formula relatively down all rows as needed.
We want to construct a regex string using our search terms across multiple columns in sheet 1, into a single cell. I used =JOIN("|", B2:E2) on sheet 1 since my search terms were in columns B:E, and this resulted in a regex that looked like this for me: alligator|dog|rabbit|lizard where alligator, dog, rabbit, and lizard, were all search terms in that row. Paste down relative as needed.
We want to run our regex against our search target cell containing the comma delimited search terms. I ran =REGEXMATCH(F2, G2) where F2 was my delimited search terms from sheet 2, and G2 was my constructed regex for the row. Paste down relative as needed.
A screenshot of my completed sheet 1:
Once you know which cells have matches you can do whatever you want.