Xoá cột có giá trị <0 or "" (1 người xem)

Liên hệ QC

Người dùng đang xem chủ đề này

overnight_9

strive for mastery
Tham gia
4/7/12
Bài viết
160
Được thích
81
Nghề nghiệp
Công nhân
dears các anh chị.
em muốn dùng code xoá dòng căn cứ theo 1 cột vd: cột X từ X24 đến X30000 (nếu trong trong vùng này cell nào có giá trị <0 hoặc "" thì delete dòng đó,

PHP:
Sub DelRows()
Dim intRow
Dim intLastRow
intLastRow = Range("X30000").End(xlUp).Row
    For intRow = intLastRow To 1 Step -1
        Rows(intRow).Select
            If Cells(24, intRow).Value < 0 Or Cells(24, intRow) = "" Then
        Cells(24, intRow).Select
        Selection.EntireRow.Delete
    End If
Next intRow
End Sub

Mà code của em nó delete sạch sẽ luôn, xin anh chị chỉ giúp.

cám ơn
 
dears các anh chị.
em muốn dùng code xoá dòng căn cứ theo 1 cột vd: cột X từ X24 đến X30000 (nếu trong trong vùng này cell nào có giá trị <0 hoặc "" thì delete dòng đó,

PHP:
Sub DelRows()
Dim intRow
Dim intLastRow
intLastRow = Range("X30000").End(xlUp).Row
    For intRow = intLastRow To 1 Step -1
        Rows(intRow).Select
            If Cells(24, intRow).Value < 0 Or Cells(24, intRow) = "" Then
        Cells(24, intRow).Select
        Selection.EntireRow.Delete
    End If
Next intRow
End Sub

Mà code của em nó delete sạch sẽ luôn, xin anh chị chỉ giúp.

cám ơn
Sub DelRows()
Dim intRow
Dim intLastRow
intLastRow
= Range("X30000").End(xlUp).Row
For intRow = intLastRow To 1 Step -1
Rows
(intRow).Select
If Cells(intRow,24).Value < 0 Or Cells(intRow,24) = "" Then
Cells
(intRow,24).Select
Selection
.EntireRow.Delete
End
If
Next intRow
End Sub


Bạn sử lại code như thế này xem
 
Upvote 0
dears các anh chị.
em muốn dùng code xoá dòng căn cứ theo 1 cột vd: cột X từ X24 đến X30000 (nếu trong trong vùng này cell nào có giá trị <0 hoặc "" thì delete dòng đó,

PHP:
Sub DelRows()
Dim intRow
Dim intLastRow
intLastRow = Range("X30000").End(xlUp).Row
    For intRow = intLastRow To 1 Step -1
        Rows(intRow).Select
            If Cells(24, intRow).Value < 0 Or Cells(24, intRow) = "" Then
        Cells(24, intRow).Select
        Selection.EntireRow.Delete
    End If
Next intRow
End Sub

Mà code của em nó delete sạch sẽ luôn, xin anh chị chỉ giúp.

cám ơn
Bạn thử như thế này xem sao:
Sub DelRows()

For I = 24 to 30000
If Range("X" & I).Value < 0 Or Range("X" & I).Value) = "" Then
Range("X" & I).Select
Selection
.EntireRow.Delete
End
If
Next I
End Sub
 
Upvote 0
dears các anh chị.
em muốn dùng code xoá dòng căn cứ theo 1 cột vd: cột X từ X24 đến X30000 (nếu trong trong vùng này cell nào có giá trị <0 hoặc "" thì delete dòng đó,

PHP:
Sub DelRows()
Dim intRow
Dim intLastRow
intLastRow = Range("X30000").End(xlUp).Row
    For intRow = intLastRow To 1 Step -1
        Rows(intRow).Select
            If Cells(24, intRow).Value < 0 Or Cells(24, intRow) = "" Then
        Cells(24, intRow).Select
        Selection.EntireRow.Delete
    End If
Next intRow
End Sub

Mà code của em nó delete sạch sẽ luôn, xin anh chị chỉ giúp.

cám ơn
Bạn có thể đối chiếu với code sau để tìm ra nguyên nhân bị sai:
PHP:
Sub DelRows1()
Dim sh As Worksheet
Dim intRow, intLastRow, intFirstRow
Set sh = ActiveSheet
intFirstRow = 1
    If sh.Range("X1") = 0 Then intFirstRow = sh.Range("X1").End(xlDown).Row
intLastRow = sh.Range("X30000").End(xlUp).Row
    For intRow = intLastRow To intFirstRow Step -1
        If sh.Cells(intRow, 24) < 0 Or sh.Cells(intRow, 24) = "" Then
            sh.Rows(intRow).EntireRow.Delete
        End If
    Next intRow
End Sub
 
Upvote 0
Bạn có thể đối chiếu với code sau để tìm ra nguyên nhân bị sai:
PHP:
Sub DelRows1()
Dim sh As Worksheet
Dim intRow, intLastRow, intFirstRow
Set sh = ActiveSheet
intFirstRow = 1
    If sh.Range("X1") = 0 Then intFirstRow = sh.Range("X1").End(xlDown).Row
intLastRow = sh.Range("X30000").End(xlUp).Row
    For intRow = intLastRow To intFirstRow Step -1
        If sh.Cells(intRow, 24) < 0 Or sh.Cells(intRow, 24) = "" Then
            sh.Rows(intRow).EntireRow.Delete
        End If
    Next intRow
End Sub

Tuyệt thật! tks a lot.
 
Upvote 0
Sai nội dung của toptic, sorry
 
Lần chỉnh sửa cuối:
Upvote 0
Web KT

Bài viết mới nhất

Back
Top Bottom