Deleting Rows On A Set Date/Time Criteria in Excel - excel

Hey I've been trying to find a way to delete the rows I need via formula without having to do change to much before it works.
When I download CSV, it stores time/date like this:
08:56  29-Sep
07:56  29-Sep
07:15  29-Sep
03:29  29-Sep
09:15  29-Sep
05:15  29-Sep
09:30  29-Sep
06:15  29-Sep
Each one being on a different row.
What I'm trying to do is delete certain rows based on a set criteria.
The criteria being Before 09:00 on today's date, and after 05:00 on tomorrow's date.
Is this possible without splitting the data up?
I've been trying to do it via IF statement, but don't use excel for much more than the basics to be honest.

Teylyn gave a TLDR while I was typing.
The longer answer, like Teylyn suggested is to flag the data.
You can use the HOUR() and ROUND() functions to extract the date/time from the string, then simply perform a simple next And/Or logic IF statement to flag yes/no for the removal.
=IF(OR(D2<0,AND(D2=0,C2<9),AND(D2=1,C2>17),D2>1),"REMOVE","KEEP")
Where column C is the extacted hour ( in 24h format ) and D is days offset from 'current' date using the following
=ROUND(A2,0)-TODAY()
Here's an example worksheet : www.instantexcel.com/downloads/stackexchange/64235111.xlsx
And a screenshot example :Multiple criterea if statement

There are several ways to achieve this.
load all the CSV data into Excel, then sort the data and delete the rows you don't need
load all the CSV data into Excel, then create a formula that flags rows you don't need, then filter the data based on that flag. This will not remove any data, only hide it from view.
load the data into Power Query instead of the worksheet and clean it up in Power Query before loading it to the worksheet.
Formulas cannot delete data. Formulas can help you identify data, and then you can use that for sorting or filtering data.

Related

Excel - issue with VLOOKUP formula - it doesn't pick dates

I need help with the below formula. I already tried to find a solution for this problem but no success.
If account number exists in column A in the 'Returns' tab and also in column A in the 'July Sales' tab, then I need to get date from the column B in 'Returns' tab.
I manually checked a few accounts on both spreadsheet and find some duplicates.
My formula is as follows:
=VLOOKUP(Returns!A:B,A:B,2,0)
Screenshots:
I tried to change format to text/general, text to columns and trim function but it's still not working.
Also, as I have over 200k rows in each table, can I use any different formula instead to speed this up?
Finally, is there any way to pick dates only if these are within 30 days
Thanks in advance.
You're using Returns!A:B as your lookup value, which doesn't make sense. Instead, try the following:
=VLOOKUP([#Account], tblReturns[[Account]:[Submit_Date]],2,FALSE)
where tblReturns is the name of the table on your Returns worksheet.
I've made the assumption that you're working with tables, since the data in your screenshots is formatted like the default table. If they're just normal ranges, the equivalent is
=VLOOKUP($A2,Returns!$A:$B,2,FALSE)
=IF(COUNTIF(RETURNS!A:A,A2)>0,B2,"NO RETURN INFO")
Not sure what you want done when the account is not found on the RETURNS worksheet. Change "NO RETURN INFO" to what ever text you want including "" for a blank. Make sure you apply the same format for cells in column F as you do in column B. Copy the above formula down as required.
try the below, which will return blanks for non-matches as opposed to errors;
=IFERROR(VLOOKUP($A2,Returns!$A:$B,2,FALSE),"")
I highly recommend an INDEX/MATCH combination over a VLOOKUP. It is MUCH faster, particularly if you are working with a large number of rows. It may even be faster than the COUNTIF solution suggested by #ForwardEd.
=IFERROR(INDEX(Returns!$B:$B,MATCH($A2,Returns!$A:$A,0)),"")

Using tables and column titles in VLOOKUP

I'm having a very difficult time with transitioning my VLOOKUP statement from simply referencing sheets and ranges (which work like a charm), to instead using table and column names.
I'm trying to make the VLOOKUP a bit more robust as the sheet where it is pulling from will constantly be changing data, so column numbers will change frequently. Thus, I'd like to just reference a column by its name.
I have converted the source data sheet to a table.
I have named all columns appropriately and double checked spelling.
This VLOOKUP works great (currently):
=VLOOKUP(E6,'Costs'!$A$2:$AE$84,19,FALSE)
However, what I would like to do is make it look this:
=VLOOKUP(E6,tblCosts[Order Number],tblCosts[June 2017], FALSE)
I have been fiddling with also trying to use MATCH which is not working either:
=VLOOKUP(E31,tblCosts[Order Number],MATCH(F4,tblCosts[June 2017],FALSE),FALSE)
UPDATE
This formula now works but it is returning the order number...not the cost for the month.
=VLOOKUP(E31,(tblCosts[Order Number]),(tblCosts[June 2017]),FALSE)
Normally I would keep trying this myself...but I am feeling overwhelmed and have been trying for hours. Any advice would be great.
Thank you!!
This should work for you:
=VLOOKUP(E31,tblCosts[#All],COLUMN(tblCosts[Jun-17]),false)
The COLUMN(TblCosts[Jun-17]) returns the column number of the field you want.
The VLookup searches the first column of tblCosts[#All] - (all the data in the table) for the data (in E31) and returns the data in the column you want.
This formula will continue to work even if you add columns or rows to the data.
Make sure that any heading which looks like a date in your spreadsheet eg "Jun-17" is stored as Text and not as a Date, as it will not match the string "Jun-17" when you use VLookup.
=VLOOKUP(E37,tblCosts[#All],match("Jun-17", tblCosts[#Headers]),FALSE)
This match is looking for the column name in all column headers and will return the number of columns to the right of the first column rather than the column number in the sheet. This avoids having to use COLUMN(tblCosts[Jun-17]) - COLUMN(tblCosts[Order Number]) + 1 when your table doesn't start in column A.
Ref: https://www.excel-university.com/vlookup-hack-4-column-labels/

Print the results of a vlookup to a cell in excel

I have been working on a solution to this problem for a few hours now and I am basically no where except knowing that I don't know how to do it...So here goes.
I want to take the original data that I have in Excel that have 'code#s' for each 'category#'. With those 'code#s', I can look up the 'category#' name.
This has been so challenging because there are a varying number of categories for every 'title#'.
I have tried printing the 'category#' name next to 'title#', but it is seemingly impossible because Excel goes through every row in the original data and gives a True, False or #N/A instead of selecting and printing only the true statements without copying down a thousand rows. I want it to go through all the possibilities and only select the categories based on the criteria that they have the same 'title#' and their lookup code matches somewhere in the lookup table.
Thanks if you can offer any sort of help.
Here are some of the formulas I have tried:
IF(AND($M$5=TOP_TREND_CONTRIBUTORS!$W$2:$W$253,MATCH(TOP_TREND_CONTRIBUTORS!$A$2:$A$253,'Category Lookup'!$D$3:$D$30,0)<>"#N/A"),TOP_TREND_CONTRIBUTORS!$A$2:$A$253,FALSE)
....where M5, W:W is the 'title#', A:A is the code for the lookup-in that part I am trying to say that they are valid if the code registers in the lookup table and the 'title#s' are equal. The last part I am trying to get it to print the 'code#s' that are valid. But that only works when I drag the formula down all the rows.
Maybe I'm missing something, but I just tried to get from your original data and lookup table to the final result. I used VLOOKUP to put categories next to titles and then used pivot table to present the data in the way you wanted (after changing some settings of pivot table and fields). Is that what you need? (some words are in Polish, it doesn't matter).

Recreating a Google Spreadsheets QUERY() in Excel

I have a massive Excel Workbook that I use for tracking product titles and descriptions, and I'm trying to get it to generate .csv files for importing those products into eBay and my own website. I'm 99% of the way there, but I can't seem to find the Excel equivalent of Google Spreadsheet's QUERY() function, and there are two spots I need to use it:
1st, I need to populate a column in SheetB with the Product IDs in SheetA that have not been listed on the site. In Google Spreadsheets, I would do this with =query('SheetA'A:B,"select A where isblank(B)") but I can't for the life of me figure out the equivalent in Excel.
2nd, I need to take all the non-blank rows from four different sheets and put them together into one sheet.
There has to be something obvious I'm missing, but I'm missing it. Help me, magical internet people, you're my only hope!
The bad news is that Excel does not have an equivalent of QUERY()
The not quite so bad news is that you can roll your own.
Some possible ways:
Move your data to a database. You can do the whole thing in the database, or still use Excel as a front end (eg by using Get External Data to query the db, or build it all in VBA)
Use AutoFilters to query your data (this is not SQL queries...). There a plenty of examples on SO of this technique
Use Get External Data (in spite of the name, this can be self referencing) to query your data (this is SQL queries) See this answer for a starter
Have a look at this short video of a 3rd party Query() function for Excel.
Here's a 5s "hello world" gif as well:
To install it, you'll need the QueryStorm runtime, which is a free 4MB installer. It's like a package manager for Excel. After you install it, go to the QueryStorm tab in the ribbon, click Extensions and install the "Windy.Query" package (as show in the video).
[Disclaimer] I'm the 3rd party (author of QueryStorm).
I was in need of doing the same, using INSERT>TABLE in Excel does the trick, from the table you create a pivot table and when you add columns and/or rows it the pivot
I know this post is 8 years old, but if anyone else is looking for a solution, you could try the following formula in cell C2
=INDEX('SheetA'$A$2:$A$10, SMALL(IF($D$2="", ROW($A$2:$A$10)-ROW($A$2)+1), ROW(1:1)))
This will look for empty cells in SheetA A Column and display ONE value in C2 cell.
If you want to extract values from B column, repeat the same formula but replace 'SheetA'$A$2:$A$10 with 'SheetA'$B$2:$B$10.
Cons: 1. you will have to copy this formula to the right and manually replace the first bit of the formula.
2. you must copy down the formula to as many rows as there are values in the SheetA to ensure you don't miss any values.
Finally: After entering the formula, press CTRL SHIFT-ENTER to convert it into an array formula.

sumif some columns value based on other column

I created the time log for what I do:
To better illustrate, I attached the image as follows:
where start and end are the time when I started the particular task in the column A, and delta is the difference between the values in End and Start.
In the next sheet, I created the the summary of how much time I spent on each criteria like this:
Now the problem I had is:
1) The formula I have in the hour field in the summary sheet is this:
=sumif('Time spent'!$A$2:$A$100,A3,'Time spent'!$D$2:$D$100)
How do I make it so that values are up for the entry put in today? The reason why I want this feature is so that I can see my performance for today.
I have this on Google Doc, but I also would like to know how to get this done in Excel as well
In Excel, starting in version 2007 you can use the SUMIFS function - which allows multiple conditions. In your case, the syntax would be:
=SUMIFS('Time spent'!$D$2:$D$100,'Time spent'!$A$2:$A$100,A3,'Time spent'!$E$2:$E$100,TODAY())
In Excel 2003, you can do this with a SUMPRODUCT:
=SUMPRODUCT('Time spent'!$D$2:$D$100*('Time spent'!$A$2:$A$100=A3)*('Time spent'!$E$2:$E$100=TODAY()))

Resources