Excel VBA 笔记

指定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"
  • 2
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值