AccessTr.neT
Excelde Tüm Sutunları Boş Olan Satırları Topluca Nasıl Silebiliriz - Baskı Önizleme

+- AccessTr.neT (https://accesstr.net)
+-- Forum: Microsoft Excel (https://accesstr.net/forum-microsoft-excel.html)
+--- Forum: Excel Cevaplanmış Soruları (https://accesstr.net/forum-excel-cevaplanmis-sorulari.html)
+--- Konu Başlığı: Excelde Tüm Sutunları Boş Olan Satırları Topluca Nasıl Silebiliriz (/konu-excelde-tum-sutunlari-bos-olan-satirlari-topluca-nasil-silebiliriz.html)

Sayfalar: 1 2 3 4


Satırı Tamamen Silmek - accessman - 14/01/2020

iyi günler
excelde satır silip alttakileri bir üste kaydırmak ile sadece satır içindekileri silmek arasında bir fark var mı
kod ile nasıl yapıyoruz


Excelde Tüm Sutunları Boş Olan Satırları Topluca Nasıl Silebiliriz - accessman - 14/01/2020

iyi günler bu soru için örnek gerekmediğini düşünüyorum. 
muhtemelen benim bilmediğim hazır bir fonksiyon vardır


Cvp: Excelde Tüm Sutunları Boş Olan Satırları Topluca Nasıl Silebiliriz - accessman - 14/01/2020

bunu Vba kodları ile nasıl yapabiliriz yoksa diğer türlü mouse + ctrl  vs ile nasıl yapılacağını bilmeyen yoktur


Cvp: Excelde Tüm Sutunları Boş Olan Satırları Topluca Nasıl Silebiliriz - accessman - 14/01/2020

mesela şöyle bir kod olur mu

Kod:
sub foo()
  dim r As Range, rows As Long, i As Long
  Set r = ActiveSheet.Range("A1:Z50")
  rows = r.rows.Count
  For i = rows To 1 Step (-1)
    If WorksheetFunction.CountA(r.rows(i)) = 0 Then r.rows(i).Delete
  Next
End Sub




Cvp: Excelde Tüm Sutunları Boş Olan Satırları Topluca Nasıl Silebiliriz - accessman - 14/01/2020

Kod:
Sub Sample()
    Dim i As Long
    Dim DelRange As Range

    On Error GoTo Whoa

    Application.ScreenUpdating = False

    For i = 1 To 50
        If Application.WorksheetFunction.CountA(Range("A" & i & ":" & "Z" & i)) = 0 Then
            If DelRange Is Nothing Then
                Set DelRange = Rows(i)
            Else
                Set DelRange = Union(DelRange, Rows(i))
            End If
        End If
    Next i

    If Not DelRange Is Nothing Then DelRange.Delete shift:=xlUp
LetsContinue:
    Application.ScreenUpdating = True

    Exit Sub
Whoa:
    MsgBox Err.Description
    Resume LetsContinue
End Sub

Set DelRange = Union(DelRange, Rows(i))
yerine
Set DelRange = Union(DelRange, Range("A" & i & ":" & "Z" & i))
de olabilir


Cvp: Excelde Tüm Sutunları Boş Olan Satırları Topluca Nasıl Silebiliriz - accessman - 14/01/2020

Kod:
Sub DeleteBlankRows()

Dim wks As Worksheet
Dim lngLastRow As Long, lngLastCol As Long, lngIdx As Long, _
    lngColCounter As Long
Dim blnAllBlank As Boolean
Dim UserInputSheet As String

UserInputSheet = Application.InputBox("Enter the name of the sheet which you wish to remove empty rows from")

Set wks = Worksheets(UserInputSheet)

With wks
    'Now that our sheet is defined, we'll find the last row and last column
    lngLastRow = .Cells.Find(What:="*", LookIn:=xlFormulas, _
                             SearchOrder:=xlByRows, _
                             SearchDirection:=xlPrevious).Row
    lngLastCol = .Cells.Find(What:="*", LookIn:=xlFormulas, _
                             SearchOrder:=xlByColumns, _
                             SearchDirection:=xlPrevious).Column

    'Since we need to delete rows, we start from the bottom and move up
    For lngIdx = lngLastRow To 1 Step -1

        'Start by setting a flag to immediately stop checking
        'if a cell is NOT blank and initializing the column counter
        blnAllBlank = True
        lngColCounter = 2

        'Check cells from left to right while the flag is True
        'and the we are within the farthest-right column
        While blnAllBlank And lngColCounter <= lngLastCol

            'If the cell is NOT blank, trip the flag and exit the loop
            If .Cells(lngIdx, lngColCounter) <> "" Then
                blnAllBlank = False
            Else
                lngColCounter = lngColCounter + 1
            End If

        Wend

        'Delete the row if the blnBlank variable is True
        If blnAllBlank Then
            .rows(lngIdx).delete
        End If

    Next lngIdx
End With


MsgBox "Blank rows have been deleted."

End Sub