jagrenet
Board Regular
- Joined
- Feb 23, 2022
- Messages
- 81
- Office Version
- 365
- 2013
- 2011
- 2010
- Platform
- Windows
Hello Gurus,
I am working with an Array(arr1) that is comparing a known or "static" list of filenames against the contents of a specific Folder. A loop runs through the list of filenames and checks the folder to verify if the file is there or not.
Dimension "1" of the Array is the filename ("i"). - Sheet1.Range("E11:E22")
Dimension "2" of the Array is the result of the comparison ("J"). - Uses Offset to indicate if file is there. It puts a "1" in the corresponding row of Column F
Everything is working beautifully - VERY well.
Now, what I would like to do, ..... since "J" already returns the count of "missing" files correctly, I want to take each missing file and create another Array (arr2), and have it return the filename to arr2, rather that the .Value of "J" which is simply 1 or "" (Empty).
And this is where I am getting stuck.
I have tried a few different code functions but still only get a numeric from "J".
Dim arr1 As Variant
arr1 = Sheet1.Range("E11").CurrentRegion 'Pass REQUIRED FILE List to Array
Dim arr2 As Variant
Dim i As Long, J As Variant
For i = LBound(arr1, 1) To UBound(arr1, 1) 'Enumerate(Index) "NAME" of file (Column "E")
For J = LBound(arr1, 2) To UBound(arr1, 2) 'Enumerate "COUNT" of file, if it exists in the folder (Column "F")
Debug.Print i, J, arr1(i, J)
Next J
Next i
Sheet1.Range("F25").Formula = "=SUM(F11:F22)"
tResult = Sheet1.Range("F25")
For Each J In arr1
If arr1(J) = "" Then
arr2 = i
Exit For
End If
Next
What am I missing ??
Thanks in advance,
Jeff
I am working with an Array(arr1) that is comparing a known or "static" list of filenames against the contents of a specific Folder. A loop runs through the list of filenames and checks the folder to verify if the file is there or not.
Dimension "1" of the Array is the filename ("i"). - Sheet1.Range("E11:E22")
Dimension "2" of the Array is the result of the comparison ("J"). - Uses Offset to indicate if file is there. It puts a "1" in the corresponding row of Column F
Everything is working beautifully - VERY well.
Now, what I would like to do, ..... since "J" already returns the count of "missing" files correctly, I want to take each missing file and create another Array (arr2), and have it return the filename to arr2, rather that the .Value of "J" which is simply 1 or "" (Empty).
And this is where I am getting stuck.
I have tried a few different code functions but still only get a numeric from "J".
Dim arr1 As Variant
arr1 = Sheet1.Range("E11").CurrentRegion 'Pass REQUIRED FILE List to Array
Dim arr2 As Variant
Dim i As Long, J As Variant
For i = LBound(arr1, 1) To UBound(arr1, 1) 'Enumerate(Index) "NAME" of file (Column "E")
For J = LBound(arr1, 2) To UBound(arr1, 2) 'Enumerate "COUNT" of file, if it exists in the folder (Column "F")
Debug.Print i, J, arr1(i, J)
Next J
Next i
Sheet1.Range("F25").Formula = "=SUM(F11:F22)"
tResult = Sheet1.Range("F25")
For Each J In arr1
If arr1(J) = "" Then
arr2 = i
Exit For
End If
Next
What am I missing ??
Thanks in advance,
Jeff