tranhungkcn
Thành viên mới

- Tham gia
- 4/1/09
- Bài viết
- 9
- Được thích
- 5
mục đích của em là khi nhập nội dung vào ô nào của cột C, ô ở hàng tương ứng của cột D sẽ tự động nhập vào một công thức, nhưng sao nó báo lỗi "Run time error '1004' application-defined or object-defined error
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim KeyCells As Range
Dim i As Integer
Set KeyCells = Range("C:C")
If Not Application.Intersect(KeyCells, Range(Target.Address)) _
Is Nothing Then
i = Target.Row
Cells(i, 4).Select
Selection.Formula = "=IFERROR(VLOOKUP(RC[-1],'ITEM master'!C1:C2,2,0),"")"
End If
End Sub
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim KeyCells As Range
Dim i As Integer
Set KeyCells = Range("C:C")
If Not Application.Intersect(KeyCells, Range(Target.Address)) _
Is Nothing Then
i = Target.Row
Cells(i, 4).Select
Selection.Formula = "=IFERROR(VLOOKUP(RC[-1],'ITEM master'!C1:C2,2,0),"")"
End If
End Sub