Bạn đưa file lên xem sao.Em có hàm như sau,
Nay em muốn chuyển nó sang VBA thì nhw thế nào, nhờ các anh chị giúp đỡMã:"=iferror(vlookup(rc[-4],taikhoan,3,0),"""")"
Trân trọng
Option Explicit
Sub Macro2()
Dim Rws As Long
Rws = [D65500].End(xlUp).Row
Range("D7").Select
ActiveCell.FormulaR1C1 = _
"=IF(RC[-3]="""","""",IF(TYPE(VLOOKUP(RC[-3],TAIKHOAN,3,FALSE))=16,""?"",VLOOKUP(RC[-3],TAIKHOAN,3,FALSE)))"
Selection.AutoFill Destination:=Range("D7:D" & Rws), Type:=xlFillDefault
Range("D7").Select
End Sub
Em gởi file. Rất mong được giúp đỡ
Sub sotk()
Dim stk, mscn As Variant, kq(), i, j As Long
mscn = Sheet5.[a8].Resize(Sheet5.[a60000].End(3).Row).Value
stk = Sheet1.[a4].Resize(Sheet1.[a60000].End(3).Row, 3).Value
ReDim kq(1 To UBound(mscn), 1 To 1)
For i = 1 To UBound(mscn)
If Not IsEmpty(mscn(i, 1)) Then
For j = 1 To UBound(stk)
If mscn(i, 1) = stk(j, 1) Then kq(i, 1) = stk(j, 3): Exit For
Next j
End If
Next i
Sheet5.[D8].Resize(i).Value = kq
End Sub




Dùng thử phương thức FIND
[GPECODE=vb]Sub SoTK()
Application.ScreenUpdating = False
Dim MSCN(), SoTaiKhoan()
Dim i As Long, Str As Range
With Sheet5
MSCN = .Range(.[A8], .[A65000].End(3)).Value
End With
ReDim SoTaiKhoan(1 To UBound(MSCN), 1 To 1)
For i = 1 To UBound(MSCN)
Set Str = Sheet1.[A:A].Find(MSCN(i, 1), , , 1)
If Not Str Is Nothing Then
SoTaiKhoan(i, 1) = Str.Offset(, 2)
End If
Next
Sheet5.[D8].Resize(i - 1, 1) = SoTaiKhoan
Set Str = Nothing
Application.ScreenUpdating = True
End Sub[/GPECODE]
SoTaiKhoan(i, 1) = Str(, 3)
Dạ.. đúng theo phong cách XÚC CẢM của anh ạ...Hình như nháy nháy theo trường phái của mình thì phải.
Nhưng đã nháy theo thì chơi luôn kiểu này nè cho ngắn thêm chút nữa
PHP:SoTaiKhoan(i, 1) = Str(, 3)
