UniqueUsername
New Member
- Joined
- Dec 9, 2022
- Messages
- 9
- Office Version
- 365
- Platform
- Windows
I have a table of data in columns A:V. In B, there is a date that I need to check if this date is more recent than the Sunday of the start of the week, 7 weeks ago. Columns C:U contain data or formulas that need to stay as they are, so I'm not able to run the check until column V.
This returns the values I need into column V.
I want to be able to only copy column C into the array, create a new column in the array for the Y/N check, then return the 2nd array column into V. Doing this current method removes the formulas I'm using to create some values. I'm also assuming this is poor practice because throwing a lot of unneeded data into the array will slow it down when I scale the project upwards.
Is there an easy way to pull work with the data in the array and return the results to a column outside of the scope of the original array?
Thanks in advance!
-Chris
VBA Code:
sub updater2000()
Dim sun7Wago As Date
Dim VALS As Variant
Dim I As Long
sun7Wago = Date - 56 'finds the date from 7 weeks ago
sun7Wago = DateAdd("D", -Weekday(sun7Wago) + 1, sun7Wago) 'finds the beginning of the week
VALS = Range("C2:V" & LROW).Value2 'declare my array
For I = 1 To UBound(VALS, 1) 'fill my array
If VALS(I, 1) > sun7Wago Then
VALS(I, 20) = "Y"
Else
VALS(I, 20) = "N"
End If
Next I
Range("C2:V" & LROW).Value2 = VALS 'plunk my array back into a table
end sub
This returns the values I need into column V.
I want to be able to only copy column C into the array, create a new column in the array for the Y/N check, then return the 2nd array column into V. Doing this current method removes the formulas I'm using to create some values. I'm also assuming this is poor practice because throwing a lot of unneeded data into the array will slow it down when I scale the project upwards.
Is there an easy way to pull work with the data in the array and return the results to a column outside of the scope of the original array?
Thanks in advance!
-Chris