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

Excel: Cancellare la riga se la cella in una certa colonna è vuota?

Advertisement

Sono un principiante completo di Excel, quindi scusatemi se è una cosa facile da fare. Ho esaminato molte opzioni ma non sono riuscito a trovare quello che mi serviva.

In sostanza, voglio cancellare tutte le righe che non contengono un valore nella colonna C. Come farei a farlo?

Lo sto facendo manualmente in questo momento per più di 5000 prodotti e mi sta facendo impazzire.

Advertisement
Advertisement

Risposte (4)

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

Si può fare questo molto rapidamente se le celle sono veramente vuote usando SpecialCells

Manuale

  • Selezionare la colonna C
  • Premere F5, poi Special
  • Controllare Blanks, poi OK, poi &007 (vedere questo passo nella foto in basso)
  • Cancellare le righe che sono ora selezionate (e. g. clic destro nella selezione > Cancellare le celle… > Entire la riga o tramite il nastro (vedi seconda schermata))

VBA

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

&004

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

Ecco un facile metodo manuale

  1. 1. Applicare un Auto Filter al foglio
  2. 2. Filtro su colonna C Vuoto
  3. Filtro su colonna &007 Vuoto
  4. Selezionare tutte le righe visibili
  5. 4. Cancellare le righe
  6. Rimuovere il filtro

Questo processo può essere automatizzato con VBA se necessario. Provare ad avviare il registratore macro per ottenere un inizio

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

Questo dovrebbe funzionare.

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

È possibile inserire questo codice nel modulo Sheet Module (tasto destro del mouse sulla scheda Sheet e selezionare “Visualizza codice”):

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

Domande correlate

6
13
9
10
10
Advertisement
Advertisement