2012-09-15 03:05:46 +0000 2012-09-15 03:05:46 +0000
24
24
Advertisement

Excel: Usuń wiersz, jeśli komórka w danej kolumnie jest pusta?

Advertisement

Jestem kompletnym nowicjuszem w Excelu, więc proszę mi wybaczyć, jeśli jest to coś łatwego do zrobienia. Przejrzałem wiele opcji, ale nie mogłem znaleźć tego, czego potrzebowałem.

Zasadniczo, chcę usunąć wszystkie wiersze, które nie zawierają wartości w kolumnie C. Jak bym to zrobił?

Robię to teraz ręcznie dla ponad 5000 produktów i doprowadza mnie to do szaleństwa.

Advertisement
Advertisement

Réponses (4)

34
34
34
2012-09-15 06:08:10 +0000

Możesz to zrobić bardzo szybko, jeśli komórki są naprawdę puste używając SpecialCells

Ręcznie

  • Wybierz kolumnę C
  • Naciśnij F5, następnie Special
  • Sprawdź Blanks, następnie OK (zobacz ten krok na zdjęciu na dole)
  • Usuń zaznaczone teraz wiersze (e. g. kliknięcie prawym przyciskiem myszy w zaznaczenie > Kasuj komórki… > Entire row lub przez wstążkę (patrz drugi zrzut ekranu)

VBA

Sub QuickCull()
    On Error Resume Next
    Columns("C").SpecialCells(xlBlanks).EntireRow.Delete
End Sub

9
9
9
2012-09-15 03:41:57 +0000

Oto prosta metoda ręczna

  1. Zastosuj Auto Filter na arkuszu
  2. Filtr na kolumnie C Puste
  3. Wybierz wszystkie widoczne rzędy
  4. Usuń wiersze
  5. Usuń filtr

Proces ten może być zautomatyzowany z VBA, jeśli jest to wymagane. Spróbuj uruchomić makrokontroler, aby rozpocząć.

0
Advertisement
0
0
2016-02-19 16:18:47 +0000
Advertisement

To powinno zadziałać.

Columns("C:C").Select
Set rngRange = Selection.CurrentRegion
lngNumRows = rngRange.Rows.Count
lngFirstRow = rngRange.Row
lngLastRow = lngFirstRow + lngNumRows - 1
lngCompareColumn = ActiveCell.Column
For lngCurrentRow = lngLastRow To lngFirstRow Step -1
If (Cells(lngCurrentRow, lngCompareColumn).Text = "") Then _
Rows(lngCurrentRow).Delete
Next lngCurrentRow
-1
-1
-1
2015-03-22 11:48:37 +0000

Możesz umieścić ten kod w module arkusza (zakładka Arkusz Kliknij prawym przyciskiem myszy i wybierz “Zobacz kod”):

Sub Delete_Blank_Rows()

'Deletes the entire row within the selection if the ENTIRE row contains no data.

'We use Long in case they have over 32,767 rows selected.

Dim i As Long
Dim LastRow As Integer

'We turn off calculation and screenupdating to speed up the macro.

 With Application
     .Calculation = xlCalculationManual
     .ScreenUpdating = False

     'Reduce the work on the calc and define the range

     LastRow = Range("A" & Rows.Count).End(xlUp).Row
     Range("A2:A" & LastRow).Select

     'We work backwards because we are deleting rows.

     For i = Selection.Rows.Count To 1 Step -1
          If WorksheetFunction.CountA(Selection.Rows(i)) = 0 Then
              Selection.Rows(i).EntireRow.Delete
          End If
     Next i

    .Calculation = xlCalculationAutomatic
    .ScreenUpdating = True
End With

End Sub
Advertisement

Questions connexes

6
13
9
10
10
Advertisement
Advertisement