How to remove blanks rows?

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.
The way I interpret this you're wanting to delete more than just blank rows,
those the likes of 2fc7c are also to be deleted. If so, try this
Code:
Sub RemoveStuff()

Dim lr As Long, i As Long

Application.ScreenUpdating = False
With Sheets("Sheet1")
    lr = .Cells(Rows.Count, "A").End(xlUp).Row
    For i = lr To 1 Step -1
        If Left(.Cells(i, "A").Value, 2) <> "X=" Then
            .Cells(i, "A").EntireRow.Delete
        End If
    Next i
End With
Application.ScreenUpdating = True
End Sub

If it is in fact just the blanks, give this a shot
Code:
Sub RemoveJustBlankLines()
    Sheets("Sheet1").Columns("A").SpecialCells(xlCellTypeBlanks).EntireRow.Delete
End Sub
 
Upvote 0
Try this:

Code:
    Cells.Select
    Selection.AutoFilter
    ActiveSheet.Range("$A$1:$F$228").AutoFilter Field:=1, Criteria1:="<>*x*", _
        Operator:=xlAnd
    Selection.Delete Shift:=xlUp
 
Upvote 0
i need only x,y coordinates rest of them need to delete

santoshloka,

Here is a macro solution for you to consider, that is based on your above quote, that does not do any looping thru the rows in your raw data Range("A1:A25").


Sample raw data flat text display:

2fc7c
X=252801.5687 Y=1965312.0195


2fc7d
X=252901.4375 Y=1965306.8999


2fc7e
X=253001.3064 Y=1965301.7802


2fc7f
X=253101.1752 Y=1965296.6605



2fc80
X=253201.0441 Y=1965291.5408


2fc81
X=253300.9130 Y=1965286.4212


And, after the macro in Range("A1:A6"):

X=252801.5687 Y=1965312.0195
X=252901.4375 Y=1965306.8999
X=253001.3064 Y=1965301.7802
X=253101.1752 Y=1965296.6605
X=253201.0441 Y=1965291.5408
X=253300.9130 Y=1965286.4212




Code:
Sub RemoveBlankRows_Plus()
' hiker95, 10/08/2017, ME1025990
Dim Addr As String
Addr = "A1:A" & Cells(Rows.Count, "A").End(xlUp).Row
Range(Addr) = Evaluate(Replace("IF(Left(@,1)<>""X"",""#N/A"",@)", "@", Addr))
On Error Resume Next
Range(Addr).SpecialCells(xlConstants, xlErrors).EntireRow.Delete
On Error GoTo 0
End Sub
 
Last edited:
Upvote 0
is it possible to sepeate them 2columns with macro
X,Y
The following is hiker95's code (which is also the way I would have coded the answer to your original question) with one additional line of code (highlighted in red) to accomplish the split across columns you are now asking for...
Code:
[table="width: 500"]
[tr]
	[td]Sub RemoveBlankRows_Plus()
  ' hiker95, 10/08/2017, ME1025990
  Dim Addr As String
  Addr = "A1:A" & Cells(Rows.Count, "A").End(xlUp).Row
  Range(Addr) = Evaluate(Replace("IF(Left(@,1)<>""X"",""#N/A"",@)", "@", Addr))
  On Error Resume Next
  Range(Addr).SpecialCells(xlConstants, xlErrors).EntireRow.Delete
  [B][COLOR="#FF0000"]Range(Addr).TextToColumns , xlDelimited, , , False, False, False, True, False[/COLOR][/B]
  On Error GoTo 0
End Sub[/td]
[/tr]
[/table]
 
Last edited:
Upvote 0
Deleted
 
Last edited:
Upvote 0
is it possible to sepeate them 2columns with macro
X,Y

santoshloka,

Here is another macro solution for you to consider that is based on your latest request.

Code:
Sub RemoveBlankRows_Plus_V2()
' hiker95, 10/08/2017, ME1025990
Dim Addr As String
Dim a As Variant, i As Long
Dim o As Variant, j As Long
Dim s
Addr = "A1:A" & Cells(Rows.Count, "A").End(xlUp).Row
Range(Addr) = Evaluate(Replace("IF(Left(@,1)<>""X"",""#N/A"",@)", "@", Addr))
On Error Resume Next
Range(Addr).SpecialCells(xlConstants, xlErrors).EntireRow.Delete
On Error GoTo 0
a = Range("A1:A" & Cells(Rows.Count, "A").End(xlUp).Row)
ReDim o(1 To UBound(a, 1), 1 To 2)
For i = LBound(a, 1) To UBound(a, 1)
  s = Split(a(i, 1), "  ")
  j = j + 1: o(j, 1) = s(0): o(j, 2) = s(1)
Next i
Range("A1").Resize(UBound(o, 1), UBound(o, 2)) = o
Columns(1).Resize(, 2).AutoFit
End Sub
 
Upvote 0

Forum statistics

Threads
1,223,893
Messages
6,175,240
Members
452,621
Latest member
Laura_PinksBTHFT

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