Excel 之 VBA 入门学习代码详解笔记(1)
1 Application 对象及基础用法
**
Sub TEXT()
Worksheets(1).Select
MsgBox "目前屏幕中显示工作表 Sheet1"
Application.ScreenUpdating = True
Worksheets(2).Select MsgBox "显示 Sheet2 了吗?"
Worksheets(3).Select
MsgBox "显示 Sheet3 了吗?"
Worksheets(2).Select
MsgBox "下面与前面执行的程序代码相同,但关闭屏幕更新功能"
Worksheets(1).Select
MsgBox "目前屏幕中显示工作表 Sheet1" & Chr(10) & "关屏屏幕更新功能"
Application.ScreenUpdating = False
Worksheets(2).Select
MsgBox "显示 Sheet2 了吗?"
Worksheets(3).Select
MsgBox "显示 Sheet3 了吗?"
Worksheets(2).Select
Application.ScreenUpdating = True
End Sub
**
Sub testStatusBar()
Application.DisplayStatusBar = True
Application.StatusBar = "http://fanjy.blog.excelhome.net"
Application.StatusBar = False
End Sub
**
Sub ViewCursors()
Application.Cursor = xlNorthwestArrow
MsgBox "您将使用箭头光标,切换到 Excel 界面查看光标形状"
Application.Cursor = xlIBeam
MsgBox "您将使用工形光标,切换到 Excel 界面查看光标形状"
Application.Cursor = xlWait
MsgBox "您将使用等待形光标,切换到 Excel 界面查看光标形状"
Application.Cursor = xlDefault
MsgBox "您已将光标恢复为缺省状态"
End Sub
**
Sub GetSystemInfo()
MsgBox "Excel 版本信息为:" & Application.CalculationVersion