Search entire workbook with two criteria - vba

Gooday, Pls I'm partially new to vba. I have several spreadsheet in a workbook for a work station that is prone to making shortage or surplus in daily delivery as a result of human errors. I want a scenario where I can search the entire workbook to extract data from Column K(which displays shortage or surplus) , but it must meet a certain criteria in Column A(date of delivery) and Column D(location of delivery). In other words, I would like to search Column K to know if there is shortage or surplus for any day I choose to search based on date. Any form of assistance is highly appreciated. Thanks.

Your solution could include an InputBox and the Range.Find Method, where you search column A for date, read in the row, and look at column K of the same row. In fact, the Range.Find example is pretty easily modified for your needs.
But you mention location in Column D, so what constraints are on column D? You'll also need to be more specific about where/how you want to extract the data from column K.

Related

Text Manipulation nestled within a Query (Or ArrayFormula) (Google Sheets)

I'm trying to Query some data in my spreadsheet, returning a manufacturer based on product code. We code our products with a three digit suffix that corresponds to different customers. I know the codes but people viewing the sheet may not.
Right now, I'm trying to split the suffix from the product and perform the wuery in the same formula.
I can do this in two steps, splitting the suffix from the code and querying just the suffix, but I want to know if I can do this all in one code. My current formula returns the data I want but it does not fill the entire range of the sheet. I would rather have this happen automatically as the workbook will be dynamic.
My current formula is:
=QUERY(CxSeries,"select B where C CONTAINS '"&right(Code,3)&"' ")
https://docs.google.com/spreadsheets/d/190kom4q0XOJP4UdLTJpZf5tuJCQTflcuokRp_FJ4pBc/edit?usp=sharing
I'm not sure if query is the right way to go about this, but I'd prefer to stick to that (just because i honestly can't wrap my head around ArrayForumlas).
Thank you,
Clear all formulas you have in column C and enter in C7
=ArrayFormula(vlookup(regexextract(D7:D16,"-(\d+)$")+0, {Sheet5!C6:C,Sheet5!B6:B}, 2, 0))

#REF! result when using INDEX function in Excel

I am trying to create a couple of reports from data on another Excel worksheet based on the value in a drop down list. I am using the MATCH and INDEX functions and have created Named Ranges of the columns of data. I am able to get the first value I want in the report but none of the others, even though when I debug by evaluating the formula it points to the right cell but still displays #REF! instead of the actual value from the referenced cell.
I'll do my best to make this clear:
In "POST_Data" worksheet I have 4 columns titled Course Name, Course Length, Attendee and Date Attended. Currently I have 33 rows of data (plus the header row) but I need the reports to be dynamic since new data will be added from time to time.
I have created Dynamic Named Ranges of the data using the OFFSET function (e.g. for the Course Name data I have a NameRange called CourseNamesData = OFFSET(POST_Data!$A$2,0,0,COUNTA(POST_Data!$A:$A),1)
In the "DashBoard_and_Data Entry" worksheet I have a two report areas: one to report the Course Name and Date Attended for a specified Attendee (specified by a drop down list in cell C7) and the other report to provide the Attendee Name and Date Attended for a specified Course Name (specified by a drop down list in I7).
In row 8 I report the column that the data belongs to in the POST_Data worksheet
What IS working: When I choose an Attendee from the drop down list in C7, I correctly report the first of the Course Names for this attendee from the data in the POST_Data worksheet. I used the following formula to do so: =INDEX(CourseNamesData,MATCH(C7,AttendeeNamesData,0),B$8)
What is NOT working: The corresponding "Date Attended" data when I use a similar formula as the one that is working. I have: =INDEX(DateAttendedData,MATCH(C7,AttendeeNamesData,0),C$8) but this gives me the #REF! error.
Again, when I try to follow the data that this formula points to, it looks like it is pointing to the correct cell but not showing the result.
Another issue is how to get all the data corresponding to the choice in the drop down and not just the first row. So for example, if I choose Richards, K. from the attendee list and he has attended 4 training courses, I need all 4 to show up, not just the first one.
I appreciate any help or insights on this. If you know of a better way to display the workbook contents, please let me know.
Thanks!
Can you provide a screenshot so that I can better understand the issue?
With regard to your post_data worksheet, you might find it easier to turn the data into a table. You can then point your named range to the column within the table without needing to use the offset function, and your range will update automatically as you add to the table.
I have a entire playlist on my youtube channel devoted to using ranges and tables if you are interested. https://www.youtube.com/playlist?list=PL1nLTDk2QLL9415OPSjIICJs1EeV-HeK3

Excel format rule highlight duplicates based on each date column entry

This excel doc is kind of like a guestbook, where there are numerous people's names and the date they visited on (written like 11/17/2014).
The doc is sorted by date, so there is like 100 or 200 names for 11/17/2014, then 200 or so for 11/18/2014... it goes on for a bunch of consecutive dates.
I want to write a formatting rule where it highlights if there are name duplicates during the duration of each day in the date column. This is to get rid of duplicates, and have an accurate representation of people visiting per day.
Things I tried:
regular dupe checker in conditional formatting - it is easy to run a dupe check all within one column. But this is a dupe check based on two columns. There will be many dupes for visitors returning daily.
The built-in formatting rule custom formula writer - it is easy to say "highlight all occurrences where column A cell and column B cell are equal" but not if the two cell patterns occurred more than once.
The Macro writer - I'm pretty rusty on visualbasic so I might be faster at generic dupe checking 100k or so entries by manually highlighting each day range.
TL;DR - Highlight all where 'name' and 'date' pattern occur more than once.
Any suggestions?
conditional formatting formula would be:
=IF(COUNTIFS($A:$A,$A1,$B:$B,$B1)>1, TRUE,FALSE)
dates in column "A", names in column "B", no difference if they are other way around, add conditional formatting whilst having all range selected and active in cell "A1". it WILL be slow though....

Excel - How do I find all relevant rows by typing unique invoice# listed Col A

I have a Worksheet with 10 columns and data range from A1:J55. Col A has the invoice # and rest of the columns have other demographic data. Goal is to type the invoice number on a cell and display all the rows matching the invoice number from col A.
Besides auto filter function, the only thing comes to my mind is VBA. Please advice what is the best way to get the data. Thanks for your help in advance.
Alright, I'm pretty proud of this one. Again avoiding VBA, this one uses the volatile formula OFFSET to keep moving its VLOOKUP search down the table until it's found all matches. Just make sure you paste enough rows of the formula that if there are many matches, there's room for all of them to appear. If you put a border around your match area then it would be clear if you ever ran out of room and needed to copy down the formula some more.
Again, in the main section, it's just a single formula (using index):
=IFERROR(INDEX($A$1:$J$200,$M3,MATCH(N$2,$A$1:$J$1,0)),"")
This gets to be so simple because the hard work of the lookup is done by an initial column which looks up the next row that matches the invoice number. It has the formula:
=IFERROR(MATCH($L$2,OFFSET($A$1:$A$200,M2,0),0)+M2," ")
Here is the working example that goes with those formulas:
Let me know if you need any further description of how it works, but it mostly uses the same rules as above so that it's robust in copying and moving around.
I've uploaded the Excel file so you can play with it, but everything you need to reproduce this feature should be in this solution.
Google Docs - Click link and hit Ctrl+S to download and open in Excel.
A popular solution to this problem is a simple VLookup. Lookup the invoice the user types in on the table A1:J55, and then return an adjascent column's data.
Here's an example of it working:
The formula in the highlighted cell is:
=VLOOKUP($L3,$A:$J,MATCH(N$2,$1:$1,0),FALSE)
What's nice about this formula is you only need to type it once and then you can copy it across and it'll automatically pick out the correct column of the table (that's the match part). The rest is very simple:
The first part says lookup value $L3 (the invoice number typed in),
The second part says look it up in range $A:$J (which is where your table is located). I've shown how you can select the entire columns $A:$J so that you can add and remove data without worrying about adjustin the range in your lookups. (Excel takes care of optimizing the formula so that unused cells aren't checked)
The third part picks the column from which the resulting data will be drawn once a matching row is found.
The FALSE part is an indication that the invoice number must match exactly (no approximate matching allowed)
The $ signs ensure that fixed ranges like the location of your source table ($A:$J) and your lookup value ($L3) don't get automatically changed as you copy the formula across for multiple columns.
The formula is pretty easy to adapt if you want to move around your table and the area where you do your lookup. Here's an example:
Bonus
If you want to add a little spiff, you can add a dropdown to the Invoice # field so that the user gets auto-completion and the option to browse existing values like so:

How do I look backwards for the most recent match of a text string in a column?

I have an Excel sheet with various data entries that are in date order going down the page, with the dates in column A. I need a formula that will take a text string from an adjacent cell, then look back up a neighbouring column for the most recent match then return the date from column A.
Currently I have this formula in cell H100: =LOOKUP(G100,E100:E$5,A100:A$5).
I want it to look for the text in G100 in column E, going backwards to find the most recent example and then return the corresponding date from column A but despite the LOOKUP command being in reverse it always returns the first example in date order, not the most recent.
I would really appreciate some help from an expert, which I am not!
I am not certain to understand the question, but try
=OFFSET($A$1, 1+MATCH(G100, E$5:E100, 0)0,1,1)
this should catch the first (higher in the sheet) instance of the lookup match.
I would bring it into an Access database where that kind of data manipulation is easy.
But then, I know how to use Access to do those kinds of things and I think it's much harder to do in Excel.