Tôi đang sử dụng VBA cho Excel 2010 và ngẫu nhiên nhận được lỗi sau:Excel VBA Run-Time Lỗi 1004
Run-time error '1004': "The sort reference is not valid. Make sure it's within the data you want to sort, and the first Sort By box isn't the same or blank."
Đây là mã
'Sort the active rows
With ActiveWorkbook.Worksheets("Product Backlog").Sort
.SetRange Range("A4:F51")
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
Nguyên nhân rất có thể là bạn không trong bảng tính bắt buộc. Không sử dụng 'ActiveWorkbook', sử dụng' Sheets ("xxxxx") '. –