Pages

How to refer to a range in another sheet

If you use multiple worksheets in a spreadsheet, then you can refer to an individual cell in a worksheet - including one that you are not currently working in - like this:
=Sheet2!B1 
(A formula like this returns the value in Worksheet Sheet2, Cell B1.)

And you can even combine values from different sheets by putting different sheet-name references into a formula like this;
=Sheet2!B1 + Sheet3!B1
(A formula like this returns the value in Worksheet Sheet2, Cell B1 plus the value in Worksheet Sheet3, Cell B1)

This makes some people think that they should refer to a range of cells in a different worksheet (eg B1:b16) like this:
=SUM(Sheet2!B1:Sheet2!B16)

However using this formula shows #ERROR! as a result, with a not-very-helpful error message of "Formula Parse Error".

Error: Formula Parse Error - message in a Google Sheets spreadsheet

The correct way to refer to a range of cells in a separate worksheet is to use the sheet-name only once, like this:
=SUM(Sheet2!B1:B16)
(A formula like this returns the sum of values in cells B1:B16 in Sheet2.)

The reason for this is that within the one function call (eg SUM(...) or AVERAGE(...) ) all the cells must come from the same worksheet. It does not make any sense to say:
=SUM(Sheet2!B1:Sheet3!B16)
because it's not defined what is in-between Sheet2 and Sheet3.

But it does make sense to combine function calls like this:
=SUM(Sheet2!B1:B16) + =SUM(Sheet3!B1:B37) 
(A formula like this returns the sum of values in cells B1:B16 in Sheet2, plus values in cells B1:B37 in Sheet3)


Extra for Experts

Of course this only works if they type of function that you are using is distributitive, ie you can do one part and the other part, and then you put them both together using the same functon, eg
= MIN ( MIN(Sheet2!B1:B16), MIN(Sheet3!B1:B22))
(A formula like this returns the smallest value in cells B1:B16 in Sheett and cells B1:B37 in Sheet3)

For functions like AVERAGE, where the number of items in the underlying range is used in the calculation, it does not work, eg
= AVERAGE ( AVERAGE(Sheet2!B1:B16), AVERAGE(Sheet3!B1:B22)) 
will give a result but it will generally not be the arithmetic mean of the value in cells B1:B16 in Sheett and cells B1:B37 in Sheet3 because the values from Sheet2 will get too great a weighting in the calculation.


Was this helpful?  You might also like: 

How to find the difference between two time values

Calculating the difference between two times (or date-times) in Google Spreadsheets is just as simple as calculating the difference between two dates, provided the time values are formatted as Times.

You simply do a "minus" between the later time and the earlier one.

At its simplest, you just do a minus calculation, like this:
C5 = C4 - C3

The result that is shows is the time differences, expressed as the number of days between the two values.

You may want to do further calculations, or apply Duration formatting, to make this number more user-friendly.



Troubleshooting

If it looks like your time difference calculation is not working correctly, then then are are few things to check.

  • Are your time values (ie not just the result) formatted as Times?
    Check this under menu: Format > Number > Time.  

    NB   It is not the same as the Font of "Times", which is totally different
  • Do you know that what is shown is the number of days, and this may be a fraction or decimal value. 
Possibly it is not  formatted the way you want it to be. 
Check the formatting under Format > Number, and remember that 15 minutes = 0.25 of an hour, or 0.010416667 of a day.


Extra for experts

A simple minus calculation only works correctly if:

  • Both times are in the same time-zone
  • If the later time is on a different day, then the values that you are calculating on must both have a "date" part as well as a "time" part.

If you need to cover these cases, then check back again soon, so see posts explaining how to handle these situations.



Was this helpful? You may also need to read

Calculating the difference between two dates
Display formats and date / time differences

Why date calculations sometimes need to have +1 added to them: whole vs partial days

When people prepare a list of start and end dates, they generally assume that the start and end date are both included.
.
For example, in my summer school management spreadsheet, start-date of 3-June actually means "9am on 3 June", and end-date of 6-June actually means "5pm on 6 June" - even though I haven't explicitly named the times.

But spreadsheets do not work like this:   if they see a date value with out a time, then they assume that it means 12-midnight at the beginning of that day.


For example, Google Spreadsheets understands
  • "start-date of 3-June" as "3-June, 00:00:00"
  • "end-date of 6-June" as "6-June, 00:00:00".

Therefore when a spreadsheet is told to calculate the difference between these two date values, if works out the number of whole days between the two values.

In the example shown, this is three days

However most people would expect the calculation to return four days, ie to include both the start-date and the end date, and the result to equal four days

There are two ways to fix this:

Option 1:  Add one to the results

Under this option, you need to change the formula

It becomes
=D4-C4+1

This is the simplest approach, and is best when you do not need to consider times in your calculations.

Option 2:  Add times to the date values

Under this option, you do not need to change the formula.

Instead you alter the values that the calculation is based on, adding a time-part to them.

This works - but the result of a difference calculation is the actual number of days between the two values, expressed as a whole number, ie with a decimal point.

eg    9am on 13 June to 5 pm on 19 June returns 4.333333333

This may be ok in some cases, eg if you just want to know if the duration is greater than a certain value.



But if you actually want to show the number of days, even if they are not complete days, then you may need to use a function like ROUNDUP(value, places)  as well as the subtraction formula.

To do this, the function becomes:
=RoundUp(D4-C4, 0)

The ", 0" in the formula says to round the value up to the nearest integer, ie number with zero decimal places.

Was this helpful? You may also need to read

Calculating the difference between two times
Display formats and date / time differences

How to show the difference between two dates

Finding out how long between two dates in a Google Spreadsheet is very simple: you just subtract the later one from the earlier one, like this:


Looking in more detail at what happens on the spreadsheet in this formula, you just need to

  • Type an equals sign ("=") - this tells the spreadsheet that you are going to put a formula into that cell
  • Type (or point to) the later value
  • Type a minus sign ("-")
  • Type (or point to) the earlier value
  • Press Enter


Google Sheets uses colour-coding in the cells and dotted lines to help you see exactly what cells the formula is pointing to.



Was this helpful?   You may also need to read:


  • Date-calculations and Plus-One: whole vs partial days
  • Calculating the difference between two times
  • Google Sheets date-format effects on calculation results

Understanding Google Sheets, Spreadsheets and Worksheets

There's a great discussion which many people have had, about the difference between email and Gmail.

The short answer is "Gmail is a type of email system".   But to really make sense of this, you need to "get" the difference between email messages, the concept of email message handling, and being able to use different front-end applications to look at the same email message. If someone doesn't have this idea, then their immediate response to "Gmail is a type of email" is "Ok then, so what is fmail?"

I have a nasty feeling that Google's choice to name all their office-applications by such generic names (Sheets, Docs, Slides) is likely to lead to the same confusion in more areas.


This post is an attempt to simply explain the basic concepts of spreadsheets, Google Sheets, and worksheets within sheets.


What is a spreadsheet?

A spreadsheet is a row-and-column based tool for working with data on a computer.

It is different from a word-processor (eg Microsoft Word or Google Docs), because it has tools that make doing mathematical / arithmetic calculations easy.

It is different from a database (eg Microsoft Access, MySQL) because it doesn't force you to put data into every single row and column that it has, and it has very easy-to-use tools to make attractive displays.

It is different from a Slides file, because it does not use slides to display the data in it.

There are various ways to organize spreadsheets, but fundamentally each one is a file that is divided up into a grid made up of rows and columns,


The intersection of each row and column is a cell.

Each cell is named according to the row and column that make it up. Normally the column name goes first, and the



In each cell you can put either text (ie words), numbers, or formulas ie calculations that take the values from other cells, combine them in some way and then display the results.

For example, the picture below shows the beginnings of a spreadsheet that contains the timetable for a summer school. I've done it in a spreadsheet, rather than an Document file, because I want to use some calculation and summary functions, as well as making it look professional.

Spreadsheet files vs Speadsheet programs

The word "spreadsheet" is actually an abbreviation.

Sometimes is it short for "spreadsheet file". This has a file which has the structure described above and which can be used by a spreadsheet program.

Sometimes it means "spreadsheet proram". This is a piece of software (aka an application) which is used to create and work with spreadsheet files. Spreadsheet programs may be on-line (like Google Sheets), or run on individual computers (like Excel or Lotus 1-2-3).

Because of this double-meaning, you can write some very strange sentences in English, eg
"I will use my spreadsheet to make a spreadsheet to calculate the spread of sheets through the hotel."
meaning
"I will use my spreadsheet-program to make a spreadsheet-file to calculate the distribution of bed linen through the hotel."

Google now distinguish between
  • Google Drive, ie the software that you use to manage files (or any type), and 
  • Google Docs ie the Document, Spreadsheet, Presentation, Form or Drawing objects that you can create inside Drive.


Spreadsheets vs Sheets / Worksheets

To start with, a spreadsheet is like a big blank canvas, waiting for you to put numbers and formulae into it.

But that size can be quite overwhelming: it can be hard to find things in spreadsheets that other people made, and it can be difficult to make different "views" which all look good, because each column has to be the same width through the whole sheet.

So the concept of Tabs was introduced. Basically the are extra layers of the the spreadsheet, stored in the same file.

In almost all spreadsheet programs (including Google Sheets), you see the tabs at the bottom left hand corner

In both Microsoft Excel and Google Sheets (the program), these tabs are called Worksheets.

But they have default names "Sheet1", "Sheet2", etc so sometimes people just call them sheets, and talk about "Sheet2 in the sheet" - and this can be very confusing if you're not sure of the difference.


If there are several worksheets in a sheet, then the name of each cell becomes:
  • The sheet name
  • An exclamation mark
  • The row-and-column reference.

In the picture above, these are all separate cells:
  • Timetable!B5 -  which is on the Timetable tab / sheet
  • Registrations!B5 - which is on the Registrations tab / sheet 
  • Sheet6!B5   -  which is on a sheet called Sheet6 (you cannot see this in the picture)


You can add a new worksheet to your Google Sheets file using the plus sign on the very left hand side of the bottom tab bar

How to combine a range of values into one cell, with a character in between them

If you have a list of items in a spreadsheet, set up like a table, then you can use the join function to combine the values and display them all together in a horizontal list, with some characters (eg a comma and a space) in between tehm..

For example, in my summer-school management spreadsheet I have a list of teachers in column C, currently in rows 1 (heading) to five.

 Teachers
-----------
 Fiona
 Patrick
 Sean
 Lynne


To put the teacher-names into the one cell, nicely formatted with a comma and a space between each one, I could use the JOIN() function, like this:
= JOIN( ", " ; C2:C5 )

But there are two problems:
  • The result is "Fiona, Patrick, Sean, Lynne, " - there is an extra "comma space" at the end
  • If the number of teachers changes, the I have to adjust the formula

A better option it to also use the FILTER() function, to remove values that you dont't want in this case, blanks which are represented by "".

So the formula becomes:
 = JOIN( ", " ; FILTER(C2:C9999; NOT(C2:C999 = "") )) 
This says to join all the values in cells C2 through to C9999 together, to put a comma and space between each one, but to leave out any that are blank,

Using this, my list becomes "Fiona, Patrick, Sean, Lynne", and I can add up to 9998 names in the Teachers column and it still works.

Extra for Experts

If I had used named ranges, and so didn't have a heading at the top of the column, then the formula could become even more flexible, with no limit to the number of rows included, like this:
= JOIN( ", " ; FILTER(C:C; NOT(C:C = "") ))
or

= JOIN( ", " ; FILTER(Teachers; NOT(Teachers = "") ))

Where to get help with Google Sheets

Google's Getting started guide:

https://support.google.com/drive/topic/20322


Google's own help pages for sheets

https://support.google.com/drive/topic/20322?hl=en-GB&ref_topic=2811806


The Google Docs product forum: 

https://productforums.google.com/forum/#!forum/docs
This has questions and answers about all types of Google Drive/ Google Docs files.


StackExchange Webapps GoogleSheets category

http://webapps.stackexchange.com/questions/tagged/google-spreadsheets
Note: answers here tend to follow the most-generic, most-complicated approach to finding a solution, and you will often by told to use a script when this is not strictly necessary. But it's an excellent place for getting scripting help.


Excel Help Forum

http://www.excelforum.com/for-other-platforms-mac-google-docs-mobile-os-etc/
This privately-run forum has a thread for other spreadsheet tools, including Google Docs.



What other help sites have you found?   

Leave a comment below, and I'll add them to the list.