Hi all,

so have a bit of a complex question that at the moment is above my VBA knowledge. Here's the context;

So I have the worksheet with the macro and where I would eventually like the data. First cell to fill with data would be B2 in sheet 1. So I have built another script that builds the file path and puts this value into U10 and the file name in U11. This should then use this information to open and find the sheet to take the data from. In the 'from sheet' the names are in column E starting at E3. Each name occurs twice or more in this column so I just want it to loop through, find a name then find the next name (it ignores the same name if it finds it again) this loop finished once it finds the word 'END' in the column and pastes it all back into the original workbook. I've started with something I have used before but need a bit of help.

Thanks in advance if you can help!

Sub getnames()

Dim oNameRange As Range
Dim oFindRng As Range

Dim sName As String
Dim sAccNo As String

Application.ScreenUpdating = False
Set oNameRange = Workbooks("names.xls").Worksheets("sheet1").Range("A1")

Do While Not oNameRange.Text = ""
    sName = Trim(oNameRange.Text)
    Workbooks("names.xls").Worksheets("sheet1").Select
    Range("C2").Select
    Do Until ActiveCell.Text = ""
        If Trim(ActiveCell.Text) = sName Then
            Do
                oNameRange.Offset(0, -1).Value = ActiveCell.Offset(0, 1).Text
                Set oNameRange = oNameRange.Offset(1, 0)
                ActiveCell.Offset(1, 0).Select
            Loop While ActiveCell.Text = sName
            GoTo NextName
        Else
            ActiveCell.Offset(1, 0).Select
        End If
    Loop
NextName:
Application.StatusBar = "Row " & oNameRange.Row & " (" & oNameRange.Text & ")"
Loop
Application.ScreenUpdating = True
End Sub