CHỈNH SỮA CODE (1 người xem)

Liên hệ QC

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

Status
Không mở trả lời sau này.

toangiaphat

Thành viên hoạt động
Tham gia
6/5/09
Bài viết
136
Được thích
3
Mình muốn xóa dòng của 1 sheet thui, tên sheet trong VBA là sheet1,
thì code sau sẽ sữa như thế nào.
thanks!

Sub Xoa2()
Dim ws As Worksheet, i As Long
For Each ws In Worksheets
With ws.UsedRange
For i = .Rows.Count To 1 Step -1
If Application.WorksheetFunction.CountA(.Rows(i).EntireRow) = 0 Then
.Rows(i).EntireRow.Delete
End If
Next i
End With
Next ws
End Sub
 
Mình muốn xóa dòng của 1 sheet thui, tên sheet trong VBA là sheet1,
thì code sau sẽ sữa như thế nào.
thanks!

Sub Xoa2()
Dim ws As Worksheet, i As Long
For Each ws In Worksheets
With ws.UsedRange
For i = .Rows.Count To 1 Step -1
If Application.WorksheetFunction.CountA(.Rows(i).EntireRow) > 0 Then
.Rows(i).EntireRow.Delete
End If
Next i
End With
Next ws
End Sub

PHP:
Sub Xoa2()
    Dim ws As Worksheet, i As Long
    For Each ws In Worksheets
        If ws.Name = "Sheet1" Then
            With ws.UsedRange
                For i = .Rows.Count To 1 Step -1
                    If Application.WorksheetFunction.CountA(.Rows(i).EntireRow) = 0 Then
                    .Rows(i).EntireRow.Delete
                    End If
                Next i
            End With
            Exit For
        End If
    Next ws
End Sub

Bạn phải sửa lại như thế này.
 
Upvote 0
Status
Không mở trả lời sau này.
Web KT

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

Back
Top Bottom