giao dien magazine

Đưa Hàm Index/Match vào Vba của Excel

Làm thế nào để đưa hàm index và hàm match chuyên tìm kiếm thông tin như dưới đây vào trong vba của Excel =INDEX(Data!B:F,MATCH(B4,Data!B:B,0),5) Dưới đây là code cần thiết để làm điều đó.

Sub Dienthoai()

Dim i As Integer
Dim LastRow1 As Long
LastRow1 = Worksheets("Free 50k").Cells(4, "B").End(xlDown).Row

Application.Interactive = False
Application.EnableEvents = False
Application.ScreenUpdating = False
For i = 4 To LastRow1


'Cells(i, 11).Value = "=INDEX(Data!B:F,MATCH(B4,Data!B:B,0),5)"


Cells(i, 11).Value = Application.Index(Worksheets("data").Range("B:F"), Application.Match(Range("B" & i), Worksheets("data").Range("B:B"), 0), 5)


Next i


Application.Interactive = True
Application.EnableEvents = True
Application.ScreenUpdating = True

End Sub

1 comment:
Write nhận xét
  1. Em hỏi với em thử INDEX(Data,and(MATCH1,match2) bằng cách tương tự với Application.and nhưng không được, nhờ ad hỗ trợ ạ

    ReplyDelete