nguyenquyetnd993
Thành viên chính thức


- Tham gia
- 31/5/19
- Bài viết
- 53
- Được thích
- 11
Chào mọi người!
Em có sưu tầm 1 được 1 code tự paste hàm sumif cho bảng tính.
Em muốn thay thế hàm mới =SUMIFS(Summary!$D:$D,Summary!$B:$B,$A6,Summary!$F:$F,">="&$A$2,Summary!$F:$F,"<="&$C$2,Summary!$I:$I,C$5) mà không đươc.
Vì nó có thêm điều kiện "<=" ">="
Mong mọi người có thể sửa dùm em với.
Em cảm ơn!
Code đây ạ:
Sub SumGroups()
Dim lastCode As Long, lastFiltCode As Long
'Determine Last Row in Column O (Unfiltered Codes)
With Sheets("Summary")
lastCode = .Range("A" & .Rows.Count).End(xlUp).Row
End With
With Sheets("Time")
'Determine last Row in Column A (Filtered Codes)
lastFiltCode = .Range("A" & .Rows.Count).End(xlUp).Row
.Range("C6:I" & lastFiltCode).Formula = _
"=SUMIFS(Summary!$D$2:$D$" & lastCode & ",Summary!$A$2:$A$" & lastCode & ",$A6,Summary!$F$2:$F$" & lastCode & ",D$5)"
End With
End Sub
Em có sưu tầm 1 được 1 code tự paste hàm sumif cho bảng tính.
Em muốn thay thế hàm mới =SUMIFS(Summary!$D:$D,Summary!$B:$B,$A6,Summary!$F:$F,">="&$A$2,Summary!$F:$F,"<="&$C$2,Summary!$I:$I,C$5) mà không đươc.
Vì nó có thêm điều kiện "<=" ">="
Mong mọi người có thể sửa dùm em với.
Em cảm ơn!
Code đây ạ:
Sub SumGroups()
Dim lastCode As Long, lastFiltCode As Long
'Determine Last Row in Column O (Unfiltered Codes)
With Sheets("Summary")
lastCode = .Range("A" & .Rows.Count).End(xlUp).Row
End With
With Sheets("Time")
'Determine last Row in Column A (Filtered Codes)
lastFiltCode = .Range("A" & .Rows.Count).End(xlUp).Row
.Range("C6:I" & lastFiltCode).Formula = _
"=SUMIFS(Summary!$D$2:$D$" & lastCode & ",Summary!$A$2:$A$" & lastCode & ",$A6,Summary!$F$2:$F$" & lastCode & ",D$5)"
End With
End Sub