Note: My question is similar Googe Spreadsheets' ImportRange function.
Is it possible in Google Spreadsheets or Microsoft Excel to import data based on cell values?
For example, can I copy contents of Sheet1 to another sheet where column B == "foo"?
Target (Sheet1):
The destination sheet should only copy Row 2 and 4 since those are the only ones containing "foo"
Edit:
For Google Docs, I am looking to something like this:
=ImportRange("spreadsheetkey", QUERY('sheetname'!A6:E10, "SELECT A, B = 'foo'")) however I can't get it to work.
You can do this just how you said but instead of using a Query in the ImportRange, you use the ImportRange in the Query, so:
=QUERY((ImportRange("spreadsheetkey", "sheetname!A6:E10")), "Select columnnumbers like Col1,Col2 etc Where _Criteria for select, such as (B contains 'foo') order by which column if you want to")
you could do something like this:
first, in an extra column (for example, column D) identify the rows / cells to be copied:
range("D" & range("A" & activesheet.rows.count).end(xlup).row).formula= "=IF(B:B=""foo"", NA(),"""")
next, use SpecialCells to select the cells in Column A, and B where Column D shows NA#
range("D1:D6").specialcells(xlcelltypeformulas, xlerrors).offset(0,-2).copy
othersheet.range("A1").pastespecial xlpasteall
that should get you started with some code to play with
of course, you can also do it without VBA, just paste the formula in, the use F5, SpecialCells dialog...
You need to wrap the query with the importrange inside of it like this:
=QUERY(importrange("spreadsheet key","sheetname!A6:E10"), "SELECT A where B='foo'")
You can do it with FILTER function:
=FILTER(IMPORTRANGE("spreadsheet_url", "'sheet_name'!A6:E10"),
IMPORTRANGE("spreadsheet_url", "'sheet_name'!B6:B10")="foo")
Related
There are a lot of questions on how to multiply all values by some other cell or to move all values to another cell based on some value, but what I want is to take, in the example image below:
All the values that I have selected and divide by 2. I do not want another column, I just want to change all those values in the spread sheet and divide them by 2, the values themselves should change.
I have not found an answer for this any where and I sure it is super simple. For example, in:
base_damage_mod selected column, 0.03 would become: 0.015.
The only way I know to do this is manually, and that's a lot of work ...
Whats the easiest way to do this?
The easiest way to do this is by writing a macro, like in the following example:
Sub Divide_by_2()
For Each c In Selection:
If c <> "" Then
c.Value = c.Value / 2
End If
Next c
End Sub
In order to launch this, you need to select your cells (no need to copy, or press Ctrl+C), and then launch the macro.
As far as the source code is concerned, this is pretty obvious, except for the c <> "" part: I have added this in order to avoid the value 0 being filled in in empty cells.
Is there a way to do this without VBA, without macros?
Yes, there is, but it involves you creating a new column, in there type a formula, then copy the values of that formula into again another column and remove the first two columns, in other words: it's quite Messi :-)
If column C is empty (if not, temporarily insert a column), enter a 2 there next to every used column D item (*).
Copy all of column C, and "Paste Special" onto column D using Operation>Divide.
(*) If there are too many items to manually do the "2", copy this formula down column C =IF(ISBLANK(D1),"",2) and it will add them. After this, convert column C from formulas to values by copying it and using "Paste Values" to paste it back. (Special Operations won't work on formulas)
I’d like to create a dynamic search box at the top of my master sheet (Sheet 1) instead of using the “Find” command, Ctrl + F. It would search column B and output info from the corresponding cell in column C.
The search box/cell would be dynamic, so as I type into it, it would pre-populate from a master list (Sheet 2), without having to hit ENTER or an OK button.
I’d like the search box/cell to be in A1
I’d like it to search column B data. From B2 to the end (row can change): B2:B
The result would be the data in column C:C2:C
Not sure if I should use the QUERY or ARRAYFORMULA function. Appreciate any thoughts on how to set this up.
how about this:
=JOIN(CHAR(10), QUERY({B2:C}, "select Col2 where Col1 contains '"&A1&"'", 0))
demo spreadsheet
I think I figured it out!
Sample Sheet
Search Box (A1): I used Data Validation. It is dynamic as I type and lists the master list of items in column A
Search Results (B1): I used VLOOKUP
Thanks, #player0, for suggesting the data validation! Really helped :)
Only issue is that I sometimes have multiple values in Column B (Item). For instance, I have "lemon" listed twice. I'd like the output in B1to show all other results. They can show in B2...Any suggestions?
EDIT: For the issue of multiples in column B, I decided to change all items in Column B to a unique identifier.
paste this in C2 cell:
=QUERY({B2:B}, "where Col1 contains '"&A1&"'", 0)
and set up dropdown data validation from B2:B range in A1 cell
demo spreadsheet
I have an excel file with multiple sheets. I reference data in sheet 2 like:
=sheet1!A1,
I would like to use a variable to change the function based on a value entered in cell x on sheet2 . I tried:
=sheet1!"x"1
to try and change all formulas based on entering a value for x. This didn't work because excel thought I was referencing something in sheet 1. I can't do this with VB due to security restrictions.
Use the indirect() function:
=INDIRECT("'Sheet1'!" & A1 & "1")
Where A1 is the cell in which you find "x".
The best way to do this is by using =INDIRECT("'Sheet1'!" & A1 & "1")
EDIT: Dang I'm too slow, Scott is like lightning.
I am trying to concatenate content of two different columns row wise but I am not getting a way by which I can do this with a single formula/condition.
name Surname
A B
C D
E F
.............
And I want to display:
A B
C D
E F
.....
I know the formula to concatenate like =CONCATENATE(A1," ",B1).
But I know that I can do this for individual rows. Is there any way by which I can do this for all rows simultaneously with single formula dependoing on number of rows?
I use a macro to do that, the macro works with selected text, you can easily change it to suit your solution:
sub Append_Text()
'Add right text to the left text
for each c in Selection
if c.Value <> "" then c.Offset(0,2).Value = c.Value & c.Offset(0,1).Value
next
end sub
You select the left side values and run the macro, it would be a good idea to assign a shortcut for the macro to speed up the process.
Let me know if this will work for you.
If you want to achieve this using a single formula such as =A1&B1,
then first convert your data as table (select a cell in your data, use the Ribbon menu Insert -> Table ) and then use the formula which will fill down automatically.
Can you please help regarding this formula in Excel 2007:
INDEX('MappFile'!F:F &"","" & 'MappFile'!G:G, MATCH(E:E,IF('MappFile'!E:E="Prod",('MappFile'!C:C)),FALSE))
The intention/purpose is the following:
'To match column E from main file
'With column C from 'Mapping File'
'Based on this take F & G from 'MappFile'
'filtering only the rows where column E from 'MappFile' = Prod
Thank you in advance!
For Vasim: this is a variant that works (syntaically) but doesn't grant the desired result:
=INDEX('MappFile'!F:F, MATCH(E:E,IF('MappFile'!E:E="Prod",('MappFile'!C:C)),FALSE))
In my example, the IF is intended to do the filtering but it must probably be done differently
EDIT: You should make an extra column that filters with your if, and then use that column as the comparison array.