Code: Select all
Sub STEP11()
Rem 1 Worksheets info
Dim Wb As Workbook
Set Wb = Workbooks.Open("C:UsersWolfieeeStyleDesktopWolfieeeStyle9.15FilesFundsCheck.xlsb")
Dim Ws1 As Worksheet: Set Ws1 = Wb.Worksheets.Item(1)
Dim Lr As Long
Let Lr = Ws1.Range("A" & Ws1.Rows.Count & "").End(xlUp).Row
Dim rngIn As Range: Set rngIn = Ws1.Range("A1:S" & Lr & "")
Dim arrIn() As Variant, arrOut() As Variant: Let arrIn() = rngIn.Value2
Dim S10Val As Double: Let S10Val = arrIn(10, 19)
Rem 2 Do it untill we are past 1000
Let arrOut() = arrIn()
Dim Cnt As Long, SomeTotal As Double
Let Cnt = 2: Let SomeTotal = arrIn(Cnt, 17)
Do
Let arrOut(Cnt, 10) = 1
Let Cnt = Cnt + 1
Let SomeTotal = SomeTotal + arrIn(Cnt, 17)
Loop While SomeTotal < S10Val
Rem 3 Output
Let rngIn.Value2 = arrOut()
Wb.Save
Wb.Close
End Sub
Line highlighted- : Let S10Val = arrIn(10, 19)
error-run time error 9
subscript out of range
This macro is giving the above error so plz have a look Sir