Tips and Tricks with Excel Bingbing Yuan Dec. 8, 2008.

19
Tips and Tricks Tips and Tricks with Excel with Excel Bingbing Yuan Bingbing Yuan Dec. 8, 2008 Dec. 8, 2008

Transcript of Tips and Tricks with Excel Bingbing Yuan Dec. 8, 2008.

Page 1: Tips and Tricks with Excel Bingbing Yuan Dec. 8, 2008.

Tips and Tricks with Tips and Tricks with ExcelExcel

Bingbing YuanBingbing Yuan

Dec. 8, 2008Dec. 8, 2008

Page 2: Tips and Tricks with Excel Bingbing Yuan Dec. 8, 2008.

22

Add a carriage return to a cell’s contentsAdd a carriage return to a cell’s contents

ProblemProblem: You need to enter a long text to a cell, each time you : You need to enter a long text to a cell, each time you press Enter to separate lines, Excel just takes you to a new cell.press Enter to separate lines, Excel just takes you to a new cell.

SolutionSolution: : PC: press PC: press Alt-EnterAlt-Enter at the end of a line at the end of a line MAC: press MAC: press Command-Option EnterCommand-Option Enter at the end of a lineat the end of a line

Page 3: Tips and Tricks with Excel Bingbing Yuan Dec. 8, 2008.

33

Get rid of spacesGet rid of spaces

TRIM()TRIM()

Page 4: Tips and Tricks with Excel Bingbing Yuan Dec. 8, 2008.

44

Gene Symbol changed by Excel Gene Symbol changed by Excel Unintended formatUnintended format

Cause:Cause:Excel automatically applies a built-in Excel automatically applies a built-in

number format to a cell, based on number format to a cell, based on the following criteria: the following criteria:

If a number contains month JAN If a number contains month JAN to DEC, it may be converted to a to DEC, it may be converted to a date format. date format.

If a number contains the letter E If a number contains the letter E (in uppercase or lowercase (in uppercase or lowercase letters; for example, 10e5), or the letters; for example, 10e5), or the number contains more characters number contains more characters than can be displayed based on than can be displayed based on the column width and font, the the column width and font, the number may be converted to number may be converted to scientific notation, or exponential, scientific notation, or exponential, format. format.

If a number contains leading If a number contains leading zeros, the leading zeros are zeros, the leading zeros are dropped.dropped.Modified from Zeeberg et.al. 2004

Page 5: Tips and Tricks with Excel Bingbing Yuan Dec. 8, 2008.

55

Gene Symbol changed by Excel: SolutionGene Symbol changed by Excel: Solution1.1. Before you populate the data into excel, select the cells that will Before you populate the data into excel, select the cells that will

contain the numbers stored as textcontain the numbers stored as text2.2. Right-click and choose Right-click and choose Format Format Cells >Text > OKCells >Text > OK3.3. If a symbol is copied from an website, you may need to use If a symbol is copied from an website, you may need to use Paste Paste

Special > TextSpecial > Text or or Unicode TextUnicode Text

Page 6: Tips and Tricks with Excel Bingbing Yuan Dec. 8, 2008.

66

Highlight duplicated cellsHighlight duplicated cells Highlight the region that Highlight the region that

may have duplicated may have duplicated valuesvalues

Format Format >>

conditional formattingconditional formatting Formula IsFormula Is: :

=COUNTIF=COUNTIF (region, cell)>1(region, cell)>1 Region: absolute rows and Region: absolute rows and

columnscolumns• $C$2:$C$15 $C$2:$C$15

Active cell: relative referenceActive cell: relative reference• C2C2

Maintain the position(s) of cell(s) in a formula: Prefix "$" to create an absolute link

Page 7: Tips and Tricks with Excel Bingbing Yuan Dec. 8, 2008.

77

Highlight duplicated cellsHighlight duplicated cells

Format Format > Patterns > choose color > OK> Patterns > choose color > OK

Page 8: Tips and Tricks with Excel Bingbing Yuan Dec. 8, 2008.

88

Remove duplicated recordsRemove duplicated records Data Data > Filter > Advanced Filter > Unique records only> Filter > Advanced Filter > Unique records only

Page 9: Tips and Tricks with Excel Bingbing Yuan Dec. 8, 2008.

99

Move to the last row in a listMove to the last row in a list

PC: PC: First cell in the active column: First cell in the active column: Ctrl + up arrowCtrl + up arrow Last cell in the active column: Last cell in the active column: Ctrl + down arrowCtrl + down arrow First cell in the active row: First cell in the active row: Ctrl + left arrowCtrl + left arrow Last cell in the active row: Last cell in the active row: Ctrl + right arrowCtrl + right arrow The very first cell (A1):The very first cell (A1): Ctrl+ HomeCtrl+ Home Bottom right corner:Bottom right corner: Ctrl+ EndCtrl+ End

MAC: MAC: use either Command or Control

Page 10: Tips and Tricks with Excel Bingbing Yuan Dec. 8, 2008.

1010

Selecting a Range of CellsSelecting a Range of Cells• Selecting a large range of cells can be a pain. Selecting a large range of cells can be a pain.

Here’s one trick that could help.Here’s one trick that could help. To start the selection of a large matrix, To start the selection of a large matrix, start by start by

selecting the bottom right cellselecting the bottom right cell of the desired matrix of the desired matrix ((Ctrl + EndCtrl + End))

Use "Use "Ctrl + Shift + up arrowCtrl + Shift + up arrow" to select everything " to select everything above the original cell. above the original cell.

Use "Use "Ctrl + Shift + left arrowCtrl + Shift + left arrow" to select everything to " to select everything to the left of the original cell. the left of the original cell.

Use "Use "Shift + down arrowShift + down arrow" to move down one row (to " to move down one row (to avoid the header line, if present). avoid the header line, if present).

Use "Use "Shift + right arrowShift + right arrow" to move to the right one " to move to the right one column (to avoid any ID column(s), if present)column (to avoid any ID column(s), if present)

Page 11: Tips and Tricks with Excel Bingbing Yuan Dec. 8, 2008.

1111

Keep headers constant as you scrollKeep headers constant as you scroll

Click the first cell in the row below the last row you want to freezeClick the first cell in the row below the last row you want to freeze Choose Choose Window >Window > Freeze Panes Freeze Panes To unfreeze frozen rows, choose To unfreeze frozen rows, choose Window > Unfreeze PanesWindow > Unfreeze Panes

Page 12: Tips and Tricks with Excel Bingbing Yuan Dec. 8, 2008.

1212

To freeze rows and columns along the top To freeze rows and columns along the top and left edges as you scrolland left edges as you scroll

Click the cell below and to the right of the rows and Click the cell below and to the right of the rows and columns you want to freezecolumns you want to freeze

Window > Window > Freeze PanesFreeze Panes

Page 13: Tips and Tricks with Excel Bingbing Yuan Dec. 8, 2008.

1313

Sort by more than 3 columnsSort by more than 3 columns

If you want to sort by columns A B C D E, select the whole If you want to sort by columns A B C D E, select the whole spreadsheet, than sort by C D E, than A B. This will spreadsheet, than sort by C D E, than A B. This will result in all five columns being sorted.result in all five columns being sorted.

Page 14: Tips and Tricks with Excel Bingbing Yuan Dec. 8, 2008.

1414

About FormulaAbout FormulaProblem: values changed due to an extra column inserted

Solution: Copy →Paste Special→Values

Page 15: Tips and Tricks with Excel Bingbing Yuan Dec. 8, 2008.

1515

Look up values in data list: vlookupLook up values in data list: vlookup

VLOOKUP(lookup_value,table_array,col_indeVLOOKUP(lookup_value,table_array,col_index_num,not_exact_match)x_num,not_exact_match) lookup_valuelookup_value : :The value to search in the first column The value to search in the first column

of the table arrayof the table array table_arraytable_array: : The table to search (containing the The table to search (containing the

value to search for in the first column) value to search for in the first column) col_index_numcol_index_num: : the column number from which the the column number from which the

matching value is returned matching value is returned not_exact_matchnot_exact_match::

• True/omitted, an exact/approximate matchTrue/omitted, an exact/approximate match• False: an exact matchFalse: an exact match

Page 16: Tips and Tricks with Excel Bingbing Yuan Dec. 8, 2008.

1616

Vlookup example Vlookup example

Too complicated? Try BaRC Submatrix Selectorhttp://iona.wi.mit.edu/bell/submatrix_selector

Page 17: Tips and Tricks with Excel Bingbing Yuan Dec. 8, 2008.

1717

MacroMacro Record macroRecord macro

Stop Recording macroStop Recording macro

Page 18: Tips and Tricks with Excel Bingbing Yuan Dec. 8, 2008.

1818

Run macroRun macro

Page 19: Tips and Tricks with Excel Bingbing Yuan Dec. 8, 2008.

1919

ReferencesReferences

• Excel Annoyances - Curtis FryeExcel Annoyances - Curtis Frye• Excel Hacks - O’ReillyExcel Hacks - O’Reilly• http://http://www.exceltip.comwww.exceltip.com (Joseph Rubin) (Joseph Rubin)• http://excel.tips.nethttp://excel.tips.net (Allen Wyatt)(Allen Wyatt)• Some Excel Basics as well as formula basics Some Excel Basics as well as formula basics

http://jura.wi.mit.edu/bio/education/bioinfo2005/ahttp://jura.wi.mit.edu/bio/education/bioinfo2005/arrays/Excel_help.htmlrrays/Excel_help.html

• Zeeberg BR, Riss J, Kane DW, Bussey KJ, Zeeberg BR, Riss J, Kane DW, Bussey KJ, Uchio E, Linehan WM, Barrett JC, Weinstein JN. Uchio E, Linehan WM, Barrett JC, Weinstein JN. BMC Bioinformatics 5:80 2004BMC Bioinformatics 5:80 2004