G'day에 변형 배열을 사용하여이런타임 오류, 엑셀 2010 VBA
그래서 희망 누군가가 여기에 무슨 일이 일어나고 있는지 알 방법이 문제에 대한 해결책에 대한 높고 낮은 검색했습니다!
코드는 다음과 같습니다. 내 이해는 배열 variant를 사용하기 때문에 long으로 i와 n을 정의해야한다는 것입니다. 지금이 순간, 내가받을거야 "런타임 오류 '1004': 응용 프로그램 정의 또는 개체 정의 오류"오류를 줄 뒤에 : 내가 가진 i와 m 변수를 대체하려고했습니다
If Cells(i, m) < Cells(i, (m-1)) Then
순수하게 테스트 용이지만 문제는 계속됩니다. 나를 알 때, 나는 뭔가 잘못 들여 썼다.
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
다른 방법으로 지정하지 않으면 'i'가 0이므로'Cells (i, 16)'은 '1004'오류를 생성합니다. 한가지 고려해야 할 점은 당신이 정말로 Variants가되기를 원할 때, 당신이'Variants'의 배열로서'Increasing'과'Decreasing'을 선언하고 있다는 것입니다. 그리고 호기심에서 벗어나 런타임 오류를 피하기위한 계획은 무엇입니까? –
나는 Lower Band of Decreasing에서 시작합니다.이 경우 10입니다. 따라서 0으로 읽지 않아야합니까? 나는 haha의 년의 처음 4 달만큼 먼 앞서 생각하지 않고 있었다! 저는 동료를 위해 기존 스프레드 시트를 적용하고 있습니다. 그녀는 9 월에 열 F에 있습니다 ... – jars121
0이 0입니다. 그것은 갚을 것이다. –