tamngominh
Thành viên mới

- Tham gia
- 20/7/18
- Bài viết
- 16
- Được thích
- 4
Dear all,
Nhờ các anh, chị giúp đỡ em muốn tạo code cho việc đánh số thứ tự
Số thứ tự tăng từ 1 đến khi hết dữ liệu của dòng
Dữ liệu em filter theo ngày
Số thứ tự em muốn điền vào cột Z
Như trong file: active cell vị trí B15 (ngày 5/8/2019), em filter ngày 5/8/2019
Em dùng offset di chuyển ra cột z (Z16) rùi
đếm số dòng có dữ liệu (trong file là 6 dòng) dùng count
em dùng loop điền số thứ tự từ 1 đến 6
Code em viết như thế
Nhờ giúp đỡ
"Sub chaysothutu()
ActiveCell.Offset(, 2).Select
Dim startnumber As Integer
Dim endnumber As Integer
Dim lastrow As Long
lastrow = Range("A1:A10000").SpecialCells(xlCellTypeVisible).SpecialCells(xlCellTypeConstants).Count
reallastrow = lastrow - 1
endnumber = reallastrow
For startnumber = 1 To endnumber
Cells(startnumber, ActiveCell).Value = startnumber
Next startnumber
End Sub"
Cam on ca nhà
Em đính kèm file!
Nhờ giúp đỡ,
Thank
Nhờ các anh, chị giúp đỡ em muốn tạo code cho việc đánh số thứ tự
Số thứ tự tăng từ 1 đến khi hết dữ liệu của dòng
Dữ liệu em filter theo ngày
Số thứ tự em muốn điền vào cột Z
Như trong file: active cell vị trí B15 (ngày 5/8/2019), em filter ngày 5/8/2019
Em dùng offset di chuyển ra cột z (Z16) rùi
đếm số dòng có dữ liệu (trong file là 6 dòng) dùng count
em dùng loop điền số thứ tự từ 1 đến 6
Code em viết như thế
Nhờ giúp đỡ
"Sub chaysothutu()
ActiveCell.Offset(, 2).Select
Dim startnumber As Integer
Dim endnumber As Integer
Dim lastrow As Long
lastrow = Range("A1:A10000").SpecialCells(xlCellTypeVisible).SpecialCells(xlCellTypeConstants).Count
reallastrow = lastrow - 1
endnumber = reallastrow
For startnumber = 1 To endnumber
Cells(startnumber, ActiveCell).Value = startnumber
Next startnumber
End Sub"
Cam on ca nhà
Bài đã được tự động gộp:
Em đính kèm file!
Nhờ giúp đỡ,
Thank