select value two columns to the left of variable in an array

mbagz

New Member
Joined
Mar 22, 2017
Messages
15
Hello, I'm trying to select a value two columns to the left of a variable cell in an array that is being looped.

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.
 

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type

Forum statistics

Threads
1,220,965
Messages
6,157,119
Members
451,398
Latest member
rjsteward

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top