#### mellymelle

##### New Member

- Joined
- Nov 25, 2016

- Messages
- 45

The code is supposed to go though a list, find all instances of a certain value and pull data based on the location of the searched value. Below is the partial code - it is the Next in the 2nd For loop that is generating the error, any suggestions are appreciated. Thanks in advance.

VBA Code:

```
Dim i As Long
Dim auaAdjLastRow As Long
Dim acct As String
auaAdjLastRow = Sheet2.Cells(Rows.Count, "T").End(xlUp).Row
For i = 2 To auaAdjLastRow
acct = Sheet2.Range("T" & i).Value2
Sheet2.Range("T" & i).Formula = Left(acct, 3) & Mid(acct, 5, 4) & Right(acct, 1)
Next i
Range("Q1").Formula = "Adjusted AUA"
Dim rng As Range
Dim rowNum As Long
Dim j As Long
Dim adjTotal As Single
For j = 2 To IPLastRow
Set rng = Sheet2.Range("T2:T" & auaAdjLastRow)
acct = Sheet1.Range("A" & j).Value2
adjTotal = 0
Do
rowNum = Application.Match(acct, rng, 0)
If Not IsError(rowNum) Then
adjTotal = adjTotal + Sheet2.Range("V" & rowNum).Value2
Set rng = Sheet2.Range("T" & rowNum + 1 & ":T" & auaAdjLastRow)
Else
rowNum = auaAdjLastRow + 1
End If
While rowNum <= auaAdjLastRow
Next j
```