duonghychi
Thành viên mới
- Tham gia
- 17/4/17
- Bài viết
- 38
- Được thích
- 3
Mong các anh chị sửa giúp đoạn code nối chuỗi ạ, em cảm ơn!
Mã:
Sub noichuoi()
Dim r As Long, i As Long, a As Long, b As Long
Dim Dict As Object
Dim Item As String, dkien As Variant, chuoi As Variant
Dim mangDieuKien As Variant, mangNoiChuoi As Variant
a = Sheet3.Range("C" & Rows.Count).End(xlUp).Row
dkien = Sheet3.Range("C10:C" & a).Value
b = Sheet2.Range("D" & Rows.Count).End(xlUp).Row
mangDieuKien = Sheet2.Range("D7:G" & b).Value
ReDim chuoi(1 To UBound(dkien, 1), 1 To 1)
For i = 1 To UBound(dkien, 1)
Set Dict = CreateObject("Scripting.Dictionary")
For r = 1 To UBound(mangDieuKien, 1)
If mangDieuKien(r, 1) = dkien(i, 1) Then
Item = mangDieuKien(r, 4)
If Not Dict.Exists(Item) And Item > "" Then
Dict.Add Item, Empty
chuoi(i, 1) = Join(Dict.Keys, ", ")
End If
End If
Next r
Next i
Sheet3.Range("L10").Resize(UBound(chuoi, 1), 1).Value = chuoi
End Sub
File đính kèm
Lần chỉnh sửa cuối: