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

Excel: ¿Borrar fila si la celda de cierta columna está en blanco?

Advertisement

Soy un completo novato en Excel, así que por favor discúlpenme si esto es algo fácil de hacer. He mirado muchas opciones pero no he podido encontrar lo que necesitaba.

Básicamente, quiero eliminar todas las filas que no contengan un valor en la columna C. ¿Cómo lo haría?

Estoy haciendo esto manualmente ahora mismo para más de 5000 productos y me está volviendo loco.

Advertisement
Advertisement

Respuestas (4)

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

Puedes hacer esto muy rápidamente si las celdas están realmente en blanco usando SpecialCells

Manual

  • Seleccionar la columna C
  • Pulsar F5, luego Special
  • Marcar Blanks, luego OK (ver este paso en la foto de abajo)
  • Eliminar las filas que ahora están seleccionadas (e. g. click derecho en la selección > Borrar celdas… > Terminar fila o a través de la cinta (ver segunda captura de pantalla)

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

Aquí hay un método manual fácil

  1. Aplique un Auto Filter a su hoja
  2. Filtro en la columna C Blanco
  3. Seleccionar todas las filas visibles
  4. Eliminar filas
  5. Eliminar el filtro

Este proceso puede automatizarse con VBA si es necesario. Pruebe a ejecutar la grabadora de macros para empezar

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

Esto debería funcionar.

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

Puedes poner este código en el módulo de la hoja (Click con el botón derecho del ratón en la pestaña de la hoja y seleccionar “Ver código”):

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

Preguntas relacionadas

6
13
9
10
3
Advertisement
Advertisement