Hi all,
So I have this code, works like a charm except it runs into a "run time error 9 subscript out of range" instead of just finishing.. It does the job and then in the last row it pops up the error. Any ideas why?
Could anyone help please?
Question posted on ExcelForum as well link: https://www.excelforum.com/excel-pr...out-of-range-in-the-last-row.html#post5070127
So I have this code, works like a charm except it runs into a "run time error 9 subscript out of range" instead of just finishing.. It does the job and then in the last row it pops up the error. Any ideas why?
Code:
Sub testing2()
Dim Dict As Scripting.Dictionary
Dim DictKey As String
Dim p As Long
Set Dict = New Scripting.Dictionary
Dict.CompareMode = TextCompare
For p = 1 To Sheet4.ListObjects("EastTable").ListRows.Count
DictKey = Join(Array(Sheet4.ListObjects("EastTable").ListRows(p).Range(1, Sheet4.ListObjects("EastTable").ListColumns("First Name").Range.Column), _
Sheet4.ListObjects("EastTable").ListRows(p).Range(1, Sheet4.ListObjects("EastTable").ListColumns("Last Name").Range.Column)), "|")
If Not Dict.Exists(DictKey) Then
Dict.Add DictKey, Nothing
Else
Sheet4.ListObjects("EastTable").ListRows(p).Delete
End If
Next
End Sub
Could anyone help please?
Question posted on ExcelForum as well link: https://www.excelforum.com/excel-pr...out-of-range-in-the-last-row.html#post5070127