Skip to main content

Excel

多個儲存格輸入

  • 選取多個儲存格
  • 輸入內容(可以是公式,會以參照位址填滿)
  • Ctrl + Enter

Enable "Developer" tab

Developer

Personal Macro / Global Macro

Reference

  • Developer
    • Record Macro
  • Store macro in
    • Personal Macro Workbook
  • Developer
    • Stop Recording

Personal Macro

Edit Personal Macro

  • Developer
    • Visual Basic
      • VBA Project (PERSONAL.xlsb)

VBA Personal.xlsb

Paste value

Sub PasteText()
' Paste:=xlPasteValues will cause 1004 error
' xlPasteAll only paste value, Bug?
Selection.PasteSpecial Paste:=xlPasteAll
End Sub

Keyboard Shortcut

Reference

DescriptionKey
Edit cellF2
New line in the same cellAlt + Enter
Paste valueCtrl + Alt + V V
Copy the the topmost cell of a selected range into the cells belowCtrl + D
Apply the General number formatCtrl + Shift + Tilde(~)
Apply the Currency formatCtrl + Shift + Dollar($)
Apply the Percentage formatCtrl + Shift + Percent(%)
Apply the Date formatCtrl + Shift + Number(#)
Apply the Time formatCtrl + Shift + At(@)
Apply the Number formatCtrl + Shift + Exclamation point(!)
Repeat the last actionCtrl + Y
Select rowShift + Space
Select columnCtrl + Space
Insert row / columnCtrl + Shift + Plus(+)
Delete row / columnCtrl + Minus(-)
Enter the current dateCtrl + Semi-colon(;)
Enter the current timeCtrl + Shift + Colon(:)
Move to edge of data rangeCtrl + Arrow
Move to edge of data rangeEnd Arrow
Open the list of validation / auto-completeAlt + Down

Note

  • Global object is Application (like window in JavaScript)

Highlight duplicates

Reference

  • Select the cells you want to check for duplicates
  • Home > Conditional Formatting > Highlight Cells Rules > Duplicate Values

Formula / Function

Operator

OperatorDescription
+Addition
Subtraction
*Multiplication
/Division
%Percent
^Exponentiation
=Equal to
>Greater than
<Less than
>=Greater than or equal to
<=Less than or equal to
<>Not equal to
&Concatenate
SpaceIntersection range

Reference

Reference

Reference to cell

<column><row>

Reference to range

<column><row>:<column><row>

Reference to column

<from column>:<to column>

Reference to row

<from row>:<to row>

Reference to sheet

[<sheet name>[:<sheet name>]!]<cell>

Absolute reference

$<column>$<row>

When editing, press F4 to change between relative and absolute

VLOOKUP

找尋 <range> 第 1 欄中等於 <value> 的列,然後傳回 <column> 所指的欄的值。如果找不到會傳回 #N/A

VLOOKUP(
<value | cell to lookup>,
<range>,
<column of return value>,
{ TRUE | FALSE }
)
TRUEApproximate match
FALSEExact match

Demo

AB
1Apple10
2Banana20
3Cat30
=VLOOKUP("Apple", A1:B3, 2, FALSE)

# 10

Equal to

VLOOKUP search from begin, but MATCH will searh from the end

=INDEX(B1:B3, MATCH("Apple", A1:A3, 0))

INDEX

Return the value of <row> in <range>

INDEX(<range>, <row>[, <column>])

MATCH

Retrun the index of <value> in <range>

MATCH(<value>, <range>, 0)

SUM

SUM(<value | range>[, ...])

IF

IF(
<expression>,
<the return value if TRUE>,
<the return value if FALSE>
)

IFS

For Excel 2016 and above

IFS(
<expression>, <the return value if TRUE>
[, ...]
)
IFS(
<expression 1>, <value 1>,
<expression 2>, <value 2>,
TRUE, <value 3>
)

same as

IF(
<expression 1>, <value 1>,
IF(<expression 2>, <value 2>, <value 3>)
)

SUMIF

SUMIF(
<range>,
"<comparison operator><value>"
<range of value to sum>
)

Demo

AB
1Apple10
2Banana20
3Apple30
4Cat40
=SUMIF(A1:A4, "=Apple", B1:B4)

# 40

SUMIFS

SUMIF(
<range of value to sum>,
<range>, "<comparison operator><value>"
[, ...]
)

Demo

ABC
1AppleRed10
2BananaYellow20
3AppleGreen30
4CatWhite40
5AppleRed50
=SUMIFS(C1:C5, A1:A5, "=Apple", B1:B5, "=Red")

# 60

=SUMIFS(C1:C5, A1:A5, "=Apple", B1:B5, "=Green")

# 30

CHOOSE

CHOOSE(<index>, <value | range>[, ...])

Equal to JavaScript

[<value>, ...][<index> - 1]