Excel VBA(1) Application Object

The Active Properties

  • ActiveCell
  • ActiveChart
  • ActivePrinter
  • ActiveSheet
  • ActiveWindow
  • ActiveWorkbook
  • Selection

Display Alerts

Application.DisplayAlerts = False
’operations...
Application.DisplayAlerts = True

 

Screen Updating

Application.ScreenUpdating = False

 

Evaluate

Evaluate("Expression")
'or
[Expression]

 

InputBox

vAnswer = Application.InputBox(Prompt:="Enter range", Type:=8)
 
Value of TypeMeaning
0A formula
1A number
2Text(a string)
4A logical value(True or False)
8A cell reference, as a Range object
16An error value, such as #N/A
64An array of values

 

eg. Get a range:

Sub GetRange()
	Dim rng As Range

	On Error Resume Next
	Set rng = Application.InputBox(Prompt:="Enter range", Type:=8)
	If rng Is Nothing Then
		MsgBox "Operation Cancelled"
	Else
		rng.Select
	End If
End Sub

 

StatusBar

Application.StatusBar = "Message"
'code operations....
'Hide message:
Application.StatusBar = False

 

SendKeys

Application.SendKeys "keysss..."
'~: Enter, %:Alter, ^:Control

 

OnTime

Application.OnTime Date + TimeSerial(15, 0, 0), "SubName"
Application.OnTime Now+ TimeSerial(0, 1, 0), "SubName"

 

OnKey

Sub AssignDown()
	Application.OnKey "{Down}", "DownTen"
End Sub

Sub DownTen()
	ActiveCell.Offset(10, 0).Select
End Sub

Sub ClearDown()
	Application.OnKey "{Down}"
End Sub

 

Worksheet Functions

 

 

Caller

转载于:https://www.cnblogs.com/kongs/archive/2012/01/17/2323597.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值