```
Sub GetValues()
' Sets Variables
Dim P As String, _
ws1 As Worksheet, _
ws2 As Worksheet, _
Y As String, _
X As String, _
rng As Range, _
lngLastColumn As Long, _
lngLastRow As Long, _
LastEntry As Long
'Sets Sheet1
Set ws1 = Sheets("Sheet1")
' Determines the last row and the last column in the table
lngLastRow = Sheets("Sheet1").Cells(Rows.Count, "A").End(xlUp).Row
lngLastColumn = Sheets("Sheet1").Cells("1", Columns.Count).End(xlToLeft).Column
' Sets the bottom right corner of the table to the variable 'Last Entry'
LastEntry = ws1.Cells(lngLastRow, lngLastColumn).Address
' Clears all values in the table
ws1.Range("C2", LastEntry).ClearContents
' Sets the initial value for Y, this corresponds to the first row in the table
Y = 2
' Initialises the outermost loop
Do
' Sets P as the name instance in column A
P = ws1.Range("A" & Y)
' Sets ws2 as the Sheet with name 'P'
Set ws2 = Sheets(P)
' Sets the initial value for X, this corresponds to the column number
X = 2
' Initialises Loop
Do
' Looks along row 1, and assigns WeekStart to the Value at column X
WeekStart = ws1.Range("A1").Offset(0, X)
' Sets where to search for the value
With ws2.Range("D:D")
' When the value is foung it sets this as the range
Set rng = .Find(WeekStart, , xlValues)
' Determines whether a value was found
If Not rng Is Nothing Then
rng1 = rng.Address
Do
' Adds the value into the appropriate column in Sheet1, if there is another
instance, it adds this on top.
ws1.Range("A" & Y).Offset(0, X) = rng.Offset(0, -1) + ws1.Range("A" & Y).Offset(0, X)
Set rng = .FindNext(rng)
Loop While Not rng Is Nothing And rng.Address <> rng1
End If
End With
' Increases the value of X by 2, to perform the same for the new column in that row
X = X + 2
Loop Until X > lngLastColumn - 1
' Increases the value of Y by 1, to perform the same for the new row in the table
Y = Y + 1
Loop Until Y > lngLastRow
End Sub
```