Yes. It is Possible.
Just follow some simple steps:
- You create a custom function by writing scripts which will work like simple function inside a Spreadsheet cell for ex: =SUM(A1 +A2) by Opening the Google Spreadsheet(That acts like directory ie. Data like name,contacts etc) ->Click Tools->Click Script Editor...
A new window will openup and choose spreadsheet option .Here,you can write custom functions which looks like
Here you write functions (for more info,https://developers.google.com/apps-script/your_first_script#requirements)
2.You create a function that will open your Spreadsheet that contains behaves like directory. A sample function
function readRows()
{
var sheet = SpreadsheetApp.openById("0AszINz88nA9hdEkxa1FIS0wta1FLS2NPUzAyU0lOV1E")
var rows = sheet.getDataRange();
var numRows = rows.getNumRows();
var values = rows.getValues();
for (var i = 0; i <= numRows - 1; i++) {
var row = values[i];
Logger.log(row);
}
};
For more info,https://developers.google.com/apps-script/reference/spreadsheet/spreadsheet-app#open(File)
You can Run and Test by pressing Run and selecting function, (it may require permission).
You can view the results in Log Window by Opening View->Logs.
That,it now you can use that function in that cell.
There are two things that you need to take into consideration.
Consideration
- The
IMPORTRANGE
function requires two parameters (strings):
- spreadsheet key
- data range
The data range needs to correspond to the number of columns you're about to use. In your case, you selected only column B and column C. Therefore, going beyond col2 will end up in failure.
- There are two distinct ways to use a parameter:
Data
Number
=QUERY( // data
IMPORTRANGE(
"0AluAYY6ZHeWYdE5XampzQVl4dVpxZ3FoVW9mUkdwQkE", // spreadsheet key
"DATA!A:C" // datarange
),
"SELECT Col1 WHERE Col3=" & C2, 0) // query
)
String
=QUERY( // data
IMPORTRANGE(
"0AluAYY6ZHeWYdE5XampzQVl4dVpxZ3FoVW9mUkdwQkE", // spreadsheet key
"DATA!A:C" // datarange
),
"SELECT Col1 WHERE Col2=" & "'" & B2 & "'" // query
)
Example
I've created an example file for you:
Best Answer
=GOOGLEFINANCE()
is appropriate. But you can also useIMPORTDATA()