query under importrange not working - spreadsheet

Hi I am new to google spreadsheet. I have open a spreadsheet name PMS having various shees in it. one of its sheet name is Overview, already formulated and gathering data from rest other sheets.
I want to extract few columns to another spreadsheet, used query(IMPORTRANGE("1yZSHctc0nCSy6Y0otufg0IXrlQXHyDBUqOEWpQ4dK94","overview!A4:M1000"),select Col1,Col2,Col6,Col7,Col8,Col12,Col13 where Col13=''",1)
But it gives me only headers. when i reduce the range to overview!A4:M34 it works and give me accurate data. I checked my overview sheet.. on row no. 35-40 column M is not ' ' and it is again blank from 41 - 80..
Please help me to tell why it is not giving data from entire sheet.

Are there numerical values in column M? If so, try this amended formula:
query(IMPORTRANGE("1yZSHctc0nCSy6Y0otufg0IXrlQXHyDBUqOEWpQ4dK94","overview!A4:M1000"),"select Col1,Col2,Col6,Col7,Col8,Col12,Col13 where Col13 is null",1)
The ='' is for text values, whereas 'is null' is used for numbers.

Related

Search entire workbook with two criteria

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.

Excel VBA: if value in row(x) = value in row (x+1) in column C then sort values in column H

I'm very new to Excel VBA.
Every month I import a spreadsheet of multiple customers' data that is already separated by customer in column C (account number). Within each account number, I need to then sort the rows into alphanumeric order based on column E (service).
In other words, I need a macro that will sort the values in column E only if the values in column C are equal to each other.
Macro must also skip any irrelevant rows, some of which contain merged cells.
FYI - the format of all the values = text, other than column I (charge amount).
Any help greatly appreciated - apologies ahead of time if I haven't made my question clear enough!
Below is a spreadsheet example:
Go to the Developer tab and click "Record Macro". Give the macro any name (Excel's suggestion is fine).
Perform the actions to sort the data, such as selct the data, swt the Sort settings etc.
Click "Stop recording" in teh developer tab.
Goto to VB and open the macro you just recorded. Use the code as a basis for your actual macro. You can record anything you want to know in additional recorded macros. The rest I leave to you. Come back when you have problems with your code.

How to copy selected columns and filter them before hand in excel VBA

I am just a beginner in VBA. I am trying to copy some data from one workbook that is updated daily to a master woorkbook and generate a report. I want it to first filter one of the columns for nonzero values and copy it with three selected columns for example columns T,C,N. I have looked everywhere for an answer but I haven't succeeded yet. Please help.
You can check if a given cell has value 0 by something like this If Sheets(sheetname).Cells(rownumber,columnnumber)=0 Then
You haven't specified what do you want to do on the other workbooks with the cells that were empty.

Excel formula or VBA script to group data

Here is a screenshot of a sample data set that I am trying to work with in Excel
I want to use either an Excel formula or a VBA script to populate the firm_anamoly column (it's manually populated right now).
The logic is that for set of rows in a given firm number, if there are more than one "sector23code"s in that set, the output in column "firm_anamoly" should be "firm_count", else "firm_anamoly" should be set to 0.
As you can see for firm_number = 5, since sector23codes are both 3 and 5, firm_anamoly is set to 3, i.e. firm_count.
I have around 500K rows of data that I am trying to work with.
Thank you.
There are 2 ways you can go about this. One way is to do it without converting your range to a table format.
Method 1:
You can enter this formula in cell D2:
{=IF(AND(IFNA(IF(A2=$A:$A,$B:$B,NA())=B2,TRUE)),0,C2)}
This will get you the results that you want I believe but it will probably overwhelm your Excel if you have a less than powerful system.
I would most recommend
Method 2:
Convert your range to an Excel table. Then enter this formula in the first row of the 'firm_anomoly' column:
{=IF(AND(IFNA(IF([#[firm_number]]=[firm_number],[sector23code],NA())=[#sector23code],TRUE)),0,[#[firm_count]])}
This version will run much more efficiently than Method 1.
Both of these are examples of Array Formulas so when you enter them hit ctrl + shift + enter to get the curly brackets to show up. Since you have so much data you should definitely back up before entering this formula; array formulas on large data sets can sometimes crash Excel.

#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