Hello, I'm trying to select a value two columns to the left of a variable cell in an array that is being looped.
Basically, my code looks for dates that are past due/coming up in a table. Each date usually has a status column to the right. One of the dates has a contract status column two columns to the left. Another date has a payment status to the left. I can easily plan for columns +1 to the right or -1 to the left. But I can't get code to work for "And Not UCase(Ray(n, Ac - 2)) = "EXECUTED" "
I know the simple fix is to re-arrange columns, but I'm trying to add a VBA script on top of a file without modifying. Can anyone help with a solution? Apologies in the advance for the poorly written VBA.
VBA Code:
Sub testing_Click()
Dim Ray As Variant, n As Long, Ac As Long, c As Long
Dim FTW As Long
Application.ScreenUpdating = False
Worksheets("Tasks").Activate
FTW = Cells(2, "U").Value
Columns("A:O").Select
Selection.ClearContents
Selection.Clear
Ray = Sheets("RawSheet").Range("B1").CurrentRegion
ReDim nray(1 To UBound(Ray, 1) * 14, 1 To 15)
'This here used to be *10, 1 To 11)
nray(1, 1) = "Project code": nray(1, 2) = "Lot": nray(1, 3) = "Sponsor"
nray(1, 4) = "Account": nray(1, 5) = "Type": nray(1, 6) = "Rep1"
nray(1, 7) = "Rep2": nray(1, 8) = "Rep3": nray(1, 9) = "Rep4"
nray(1, 10) = "Budget": nray(1, 11) = "Amount": nray(1, 12) = "Task #n"
nray(1, 13) = "Expected date": nray(1, 14) = "Status of Task #n": nray(1, 15) = "Days until Deadline"
c = 1
For n = 3 To UBound(Ray, 1)
For Ac = 25 To UBound(Ray, 2)
If IsDate(Ray(n, Ac)) Then
If DateDiff("d", Date, Ray(n, Ac)) < FTW And Not UCase(Ray(n, Ac + 1)) = "DONE" And Not UCase(Ray(n, Ac - 2)) = "EXECUTED" And Not UCase(Ray(n, Ac - 1)) = "FUNDS PAID" Then
c = c + 1
Basically, my code looks for dates that are past due/coming up in a table. Each date usually has a status column to the right. One of the dates has a contract status column two columns to the left. Another date has a payment status to the left. I can easily plan for columns +1 to the right or -1 to the left. But I can't get code to work for "And Not UCase(Ray(n, Ac - 2)) = "EXECUTED" "
I know the simple fix is to re-arrange columns, but I'm trying to add a VBA script on top of a file without modifying. Can anyone help with a solution? Apologies in the advance for the poorly written VBA.