Farscape2020
New Member
- Joined
- Mar 22, 2020
- Messages
- 17
- Office Version
- 365
- Platform
- Windows
Good Day,
I am having difficulty with my arrays in vba. In my Excel file, I have 10 worksheets representing the months from September until June. After downloading a csv file and sorting the data (by month and then by day), I add the the range for each month to an array using the following code
where "i" is the iterator from 1 to 12 (1 for January, 2 for February, and so on.). Search column is a function that searches column J to determine if "i" (or the month) is listed in the csv file. The findLastRow() is a function to find the last row of the data. When I run the macro, September populates without an issue. However, when it attempts to add the data for October, the data is not added to the array. See Below
Would anyone be able to hazard a guess as to why the array would populate for September (i = 9) and not for October (i =10)? Please let me know if you require any further information.
Thank you for you help.
I am having difficulty with my arrays in vba. In my Excel file, I have 10 worksheets representing the months from September until June. After downloading a csv file and sorting the data (by month and then by day), I add the the range for each month to an array using the following code
VBA Code:
If GetArrLength(attendanceArr) > 0 Then
Erase attendanceArr
End If
If searchColumn(attendanceSheet, "J", i) = True Then
With attendanceSheet
startRow = .Range("J1:J" & findLastRow(attendanceSheet, "J")).Find(what:=i, after:=.Range("J1")).row
endRow = .Range("J1:J" & findLastRow(attendanceSheet, "J")).Find(what:=i, after:=.Range("J1"), searchdirection:=xlPrevious).row
End With
attendanceArr = Range("A" & startRow & ":" & attendanceSheetLastLetter & endRow)
where "i" is the iterator from 1 to 12 (1 for January, 2 for February, and so on.). Search column is a function that searches column J to determine if "i" (or the month) is listed in the csv file. The findLastRow() is a function to find the last row of the data. When I run the macro, September populates without an issue. However, when it attempts to add the data for October, the data is not added to the array. See Below
Would anyone be able to hazard a guess as to why the array would populate for September (i = 9) and not for October (i =10)? Please let me know if you require any further information.
Thank you for you help.