The below mentioned code reads data from a workbook and stores it in various arrays, then it enters a loop to open another workbook to enter values stored in the array in specific tabs and locations.
Once entered, it calls another subroutine form the newly opened workbook, subroutine runs fine (takes 2-3 mins) to run, but then code automatically exits the loop (I mean it doesn't open the next file in the loop). Is it because of the processing time of the called macro? I could use some insight regarding the issue, it would be very helpful. Thanks in advance :)
Public strFileName As String
Public strfilename2 As String
Public currentWB As Workbook
Public dataWB As Workbook
Sub GetData()
Dim strListSheet As String
Dim ws As Worksheet
Dim Tabnames() As Variant
Dim celladdress() As Variant
Dim values() As Variant
Dim tabcount As Integer
Dim filecount As Integer
Dim j As Integer
Dim k As Integer
Dim i As Integer
strListSheet = "Data_Specifics"
Sheets(strListSheet).Select
tabcount = WorksheetFunction.CountA(Rows(6)) - 1
filecount = WorksheetFunction.CountA(Columns(2)) - 4
ReDim Tabnames(0, 0 To tabcount - 1)
ReDim celladdress(0, 0 To tabcount - 1)
ReDim values(0 To filecount - 1, 0 To tabcount - 1)
For k = 0 To tabcount - 1
Tabnames(j, k) = ActiveWorkbook.Sheets(strListSheet).Cells(6, k + 4).Value
celladdress(j, k) = ActiveWorkbook.Sheets(strListSheet).Cells(7, k + 4).Value
Next k
For j = 0 To filecount - 1
For k = 0 To tabcount - 1
values(j, k) = ActiveWorkbook.Sheets(strListSheet).Cells(j + 9, k + 4).Value
Next k
Next j
Range("B8").Select
i = -1
Set currentWB = ActiveWorkbook
Do While ActiveCell.Value <> ""
strFileName = ActiveCell.Offset(1, 1)
strfilename2 = ActiveCell.Offset(1, 0)
Application.Workbooks.Open strFileName, UpdateLinks:=False, ReadOnly:=False
Set dataWB = ActiveWorkbook
i = i + 1
For k = 0 To tabcount - 1
Sheets(Tabnames(0, k)).Select
Range(celladdress(0, k)).Select
If values(i, k) <> "XXXXX" Then
Selection.Value = values(i, k)
Else
End If
Next k
strfilename2 = "'" & strfilename2 & "'" & "!ValidateDataNew"
Application.Run strfilename2
dataWB.Close SaveChanges:=True
currentWB.Activate
Sheets(strListSheet).Select
ActiveCell.Offset(1, 0).Select
i = i
Loop
Exit Sub
End Sub