天,
我一直在寻找解决这个问题的方法,所以希望这里有人知道发生了什么!
到目前为止我得到的代码如下。我的理解是我需要将 i 和 n 定义为 Long,因为它们使用数组变体?目前,我在以下行后收到“运行时错误'1004':应用程序定义或对象定义错误”错误:
If Cells(i, m) < Cells(i, (m-1)) Then
我已经尝试用整数替换 i 和 m 变量,纯粹是为了测试目的,但问题仍然存在。了解我,我缩进了一些错误的东西:|
Option Explicit
Public Sub Show_Arrows()
Dim i As Integer
Dim n As Integer
Dim m As Integer
Dim Increasing() As Variant
Dim Decreasing() As Variant
Decreasing = Array(10, 11, 16, 17, 18, 19)
Increasing = Array(12, 13, 22, 25, 26, 31, 32, 36, 37, 38, 39, 40, 41, 44, 45, 46, 47, 50, 51, 52, 55, 58)
m = (Month(Date) - 4)
For i = LBound(Decreasing) To UBound(Decreasing)
Cells(i, 16).Select
If Cells(i, m) < Cells(i, (m - 1)) Then
ActiveSheet.Pictures.Insert("C:\Users\jamie.rosssmith\Documents\Visual Basic Programming\Arrows - Vanessa\Green.png").Select
ElseIf Cells(i, m) > Cells(i, (m - 1)) Then
ActiveSheet.Pictures.Insert("C:\Users\jamie.rosssmith\Documents\Visual Basic Programming\Arrows - Vanessa\Red.png").Select
End If
Next
For n = LBound(Increasing) To UBound(Increasing)
Cells(n, 16).Select
If Cells(n, m) > Cells(n, (m - 1)) Then
ActiveSheet.Pictures.Insert("C:\Users\jamie.rosssmith\Documents\Visual Basic Programming\Arrows - Vanessa\Green.png").Select
ElseIf Cells(n, m) < Cells(n, (m - 1)) Then
ActiveSheet.Pictures.Insert("C:\Users\jamie.rosssmith\Documents\Visual Basic Programming\Arrows - Vanessa\Red.png").Select
End If
Next
End Sub