Sub gpeguilaicongthuc()
Dim c1&, c2&, c3&, s$, eCol&, r&
On Error Resume Next
With Sheet1
eCol = .Cells(1, Columns.Count).End(xlToLeft).Column
c1 = .Cells(1, 1).Resize(1, eCol).Find("[KhoiLuong]", , , 1).Column
c2 = .Cells(1, 1).Resize(1, eCol).Find("[dientich]", , , 1).Column
c3 = .Cells(1, 1).Resize(1, eCol).Find("[ThanhTien]", , , 1).Column
If c1 = 0 Or c2 = 0 Or c3 = 0 Then
s = Application.Trim(IIf(c1 = 0, "[KhoiLuong] ", "") & IIf(c2 = 0, "[dientich] ", "") & IIf(c3 = 0, "[ThanhTien] ", ""))
MsgBox "Kiem tra cot: " & s, vbOKOnly, "Canh bao"
Else
r = .Cells(1048576, c1).End(xlUp).Row
If r > 1 Then
.Cells(2, c3).Formula = "=CONCATENATE(" & .Cells(2, c1).Address(0, 0) & ",""_""," & .Cells(2, c2).Address(0, 0) & ")"
.Cells(2, c3).Resize(r - 1, 1).FillDown
End If
End If
End With
End Sub