admin管理员组文章数量:1530518
2024年3月21日发(作者:)
Excel,VBA,VB语法基础介绍
Excel VBA
VB 语法基础 介绍
目标 了解 VB 基本语法规则 可以编写简单的代码
一切从宏开始
录制的宏是由 Sub 定义的子过程 [ Private | Public | Friend] [ Static] Sub name
[( ( arglist ) )]
[ statements ] [ Exit Sub] [ statements ] End Sub
Sub Macro1()
With
.Color = -__
.TintAndShade = 0
End With End Sub
将子过程修改为有返回值的函数
[ Public | Private | Friend] [ Static] Function name
[( ( arglist ) )] [ As type ] [ statements ] [ name
= = expression ] [ Exit Function]
[ statements ] [ name
= = expression ] End Function
‘ 返回指定单元格的字体颜色 Funcion GetFontColor(Target As Range) As Long Dim
lCellColor As Long
If IsNumeric() Then
lCellColor =
End If
GetFontColor = lCellColor End Sub
几何运算函数
‘ 计算圆的面积 Function CircleArea(R As Double) As Double Const PI As Double =
3.__979
CircleArea = PI * R ^ 2 End Function
版权声明:本文标题:Excel,VBA,VB语法基础介绍 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://m.elefans.com/xitong/1710970345a292946.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论