[ad_1]
I am compaining two sheet by first column then getting value from 10th column.But its not looping thru all value from data sheet.
Sub Summarize()
Dim i, n As Long, ws1 As Worksheet, ws2 As Worksheet, data, client, mainsht
Set ws1 = ThisWorkbook.sheets("Sheet1")
Set ws2 = ThisWorkbook.sheets("Sheet2")
data = ws2.Range("A2:G" & ws1.Cells(Rows.Count, 2).End(xlUp).Row).Value 'data to array
For n = 2 To ws1.Range("A2").End(xlDown).Row 'loop over rows in the mainsheet (sheet1)
For i = 1 To UBound(data, 1) 'loop over rows in the array in data (sheet2)
Debug.Print data(i, 1)
If ws1.Cells(n, 1) = data(i, 1) Then 'if client name from mainsheet matches to data sheet
ws1.Cells(n, 10) = ws1.Cells(n, 10) & " " & data(i, 2) & ","
End If
Next
Next
End Sub
[ad_2]