Ayuda para eliminar espacios en blanco

yra_vj

New Member
Joined
Mar 29, 2007
Messages
18
Hola buen dia

Quisiera que por favor me ayudaran a modificar mi macro ya que estoy trabajando con un archivo que contiene varios espacios en blanco, esto lo habia solucionado aplicandole filtros, pero cuando este reporte cambia y trae mas informacion mi macro ya no funciona,ya que el tamaño del reporte varia, alguien puede darme una idea de que puedo hacer para que elimine todo aquello que tenga espacios en blanco para que me pueda quedar con todo aquello que contiene informacion??

esta es la macro que hice:

Code:
Sub EliminarEsp()
Rows("1:6").Select
Range("A6").Activate
Selection.Delete Shift:=xlUp
Rows("1:1").Select
Selection.Delete Shift:=xlUp
Rows("2:2").Select
Selection.Delete Shift:=xlUp
Columns("I:I").Select
Selection.Delete Shift:=xlToLeft
Range("A1").Select
ActiveCell.FormulaR1C1 = "CTA"
Range("B1").Select
ActiveCell.FormulaR1C1 = "DESC"
Range("C1").Select
ActiveCell.FormulaR1C1 = "S1"
Range("C1").Select
ActiveCell.FormulaR1C1 = "Div"
Range("H1").Select
ActiveCell.FormulaR1C1 = "TH"
Range("G1").Select
ActiveCell.FormulaR1C1 = "TH"
Range("F1").Select
ActiveCell.FormulaR1C1 = "S2"
Range("E1").Select
ActiveCell.FormulaR1C1 = "ANT"
Range("D1").Select
ActiveCell.FormulaR1C1 = "ST"
Range("A1").Select
Range(Selection, Selection.End(xlToRight)).Select
Range(Selection, Selection.End(xlDown)).Select
Range(Selection, Selection.End(xlDown)).Select
Range(Selection, Selection.End(xlDown)).Select
Range(Selection, Selection.End(xlDown)).Select
Range("A1:H400").Select
Selection.AutoFilter
Selection.AutoFilter Field:=1, Criteria1:="="
Selection.AutoFilter Field:=2, Criteria1:="="
Selection.AutoFilter Field:=3, Criteria1:="="
Selection.AutoFilter Field:=4, Criteria1:="="
Selection.AutoFilter Field:=5, Criteria1:="="
Selection.AutoFilter Field:=6, Criteria1:="="
Selection.AutoFilter Field:=7, Criteria1:="="
Selection.AutoFilter Field:=8, Criteria1:="="
Range("A5:IT15").Select
Range(Selection, Selection.End(xlToLeft)).Select
Range("A5:H299").Select
Selection.EntireRow.Delete
Range("A1").Select
Selection.AutoFilter
End Sub
 
Last edited by a moderator:

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple
Trataré de pasar después para explicar todo esto mejor, pero si no me equivoco, usted puede contraer su código hasta así:
Code:
Sub EliminarEsp()
    Rows("1:8").EntireRow.Delete
    Columns("I:I").EntireColumn.Delete
    Range("A1:H1") = Array("CTA", "DESC", "Div", "ST", "ANT", "S2", "TH", "TH")
    With ActiveSheet.UsedRange
        For i = 1 To 8
            .AutoFilter Field:=i, Criteria1:="="
        Next i
        .Offset(1).EntireRow.Delete
    End With
End Sub
 
Upvote 0

Forum statistics

Threads
1,223,967
Messages
6,175,674
Members
452,666
Latest member
AllexDee

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top