指定Cells (S4)
' One Cell
(B5)
' Part of a Column
(B5:B9)
' Part of a Row
(B5:E5)
' Matrix of Cells
(B5:E9)
' Unrelated Cells
(B5, B9, E9)
' Entire Column
(B:B)
' Entire Row
(5:5)
' Multiple Columns
(B:C)
' Multiple Rows
(5:7)
(S5)
VBA (S13)
Sub Hello()
MsgBox "This is body msg in msgbox", vbInformation, "Head title"
End Sub
vbInformation 是指图标,部分图标包括:
无:vbDefaultButton1
!:vbExclamation
X :vbCritical
i :vbInformation
?:vbQuestion
If / else (S15)
Dim Age
Age = InputBox("How old are you?")
if Age = 12 Then
Range("B3").Value = "12 years old only"
End If
If Age >= 18 Then
Range("B4").Value = _
"Adult. "
Else
Range("B4").Value = _
"Kid. "
End If
Loop (S16)
方法1
While ActiveCell.Row <= 10
' Put Row number into first cell
Active.Value = "I am row " & ActiveCell.Row
' Move the selection down one cell
ActiveCell.Offset(1,0).Select
Wend
方法2(效果同上)
Do While ActiveCell.Row <= 10
' Put Row number into first cell
Active.Value = "I am row " & ActiveCell.Row
' Move the selection down one cell
ActiveCell.Offset(1,0).Select
Loop
方法3(先把内容跑一遍再决定是否Loop)
Do
' Ask a question
Answer = InputBox ( _
" Are you above 18 years old ?")
Loop While LCase(Answer) <> "yes"