作者:乔山办公网日期:
返回目录:excel表格制作
在 Worksheet.Change 中加入e69da5e6ba90e799bee5baa6e997aee7ad94361以下代码便可实现你要的效果:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim lngRow As Long
lngRow = Target.Row
If lngRow = 5 Then
Dim lngCol As Long
lngCol = Target.Column
If (lngCol = 3) Or (lngCol = 4) Then
Application.EnableEvents = False
If lngCol = 3 Then
With Target.Offset(, 1)
.FormulaR1C1 = "=R[-1]C[-1]-RC[-1]"
.Value2 = .Value2
End With
Else
With Target.Offset(, -1)
.FormulaR1C1 = "=R[-1]C-RC[1]"
.Value2 = .Value2
End With
End If
Application.EnableEvents = True
End If
End If
End Sub
动画效果:
那是定义变来量。%表示整数型,$表示字符串型,具体对应如下:
数据类型 类型标识符 字节
字符串型 String $ 字符长度(0-65400)
字节型 Byte 无源 百1
布尔型 Boolean 无 2
整数型 Integer % 2
长整数型 Long & 4
单精度型 Single ! 度4
双精度型 Double # 8
日期型 Date 无 8公元100/1/1-99/12/31
货币型 Currency @ 8
小数点型 Decimal 无 14
变体型 Variant 无 以上任意类型,可变
对象型 Object 无 4
1、首先是打开excel软件。
2、然后打开VBA编程接口。
3、接下来是定义执copy行功能。
4、然后介绍局部变量的定义,定义为[dim variable as type]。
5、然后定义私有变量,定义方式为[private variable as type]。
6、然后定义公共变量,定义方法[public variable as type]。
7、最zhidao后,定义静态变量,例如[static variable as type]。
plhang(122)
这是定义一个数组,开始从0开始也就是123个元素的一维数组