EXCEL使用VBA的问题
Subauto_open()a=Range("C86")DimxAsDoubleDimyAsDoubleDimminAsDoubleDimmxAsDoubleDimmyA...
Sub auto_open()
a = Range("C86")
Dim x As Double
Dim y As Double
Dim min As Double
Dim mx As Double
Dim my As Double
min = 2000
mx = 2000
my = 1
For x = 1 To 2000
For y = 1 To 2000
If Abs(x / y - a) < min Then
min = Abs(x / y - a)
mx = x
my = y
End If
Next
Next
Range("F58").Value = mx
Range("F60").Value = my
End Sub
这是我的代码,这段代码执行的结果是当单元格C86的值改变后需要存盘重新启动EXSEL才计算F58和F60,我想让C86的值改变后马上就计算,而不要存盘再启动,能实现吗?怎么改?
我想实现的效果就想是单元格内输入公式那样.shuhua0715你说的那个意思是将Sub auto_open()换成Private Sub Worksheet_SelectionChange(ByVal Target As Range)吗?还在原来的位置更换就行吗?不好用啊! 展开
a = Range("C86")
Dim x As Double
Dim y As Double
Dim min As Double
Dim mx As Double
Dim my As Double
min = 2000
mx = 2000
my = 1
For x = 1 To 2000
For y = 1 To 2000
If Abs(x / y - a) < min Then
min = Abs(x / y - a)
mx = x
my = y
End If
Next
Next
Range("F58").Value = mx
Range("F60").Value = my
End Sub
这是我的代码,这段代码执行的结果是当单元格C86的值改变后需要存盘重新启动EXSEL才计算F58和F60,我想让C86的值改变后马上就计算,而不要存盘再启动,能实现吗?怎么改?
我想实现的效果就想是单元格内输入公式那样.shuhua0715你说的那个意思是将Sub auto_open()换成Private Sub Worksheet_SelectionChange(ByVal Target As Range)吗?还在原来的位置更换就行吗?不好用啊! 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询