ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Deleting non empty rows (https://www.excelbanter.com/excel-programming/343553-deleting-non-empty-rows.html)

Jan Kronsell

Deleting non empty rows
 
This code deletes the row, if the cell in column C IS empty.

Sub SletBlank()
On Error Resume Next
Columns("C:C").SpecialCells(xlCellTypeBlanks).Enti reRow.Delete
End Sub

I need it to do it, the other way around. Delete all rows, where the cell in
column C IS NOT empty. But there is no xlCellType for "Nonblank". So how do
I best do what I want.

Jan



Norman Jones

Deleting non empty rows
 
Hi Jan,

Try:

Sub Tester()
On Error Resume Next
With Range("C:C")
.SpecialCells(xlCellTypeConstants).Delete
.SpecialCells(xlCellTypeFormulas).Delete

On Error GoTo 0
End With

End Sub

---
Regards,
Norman


"Jan Kronsell" wrote in message
...
This code deletes the row, if the cell in column C IS empty.

Sub SletBlank()
On Error Resume Next
Columns("C:C").SpecialCells(xlCellTypeBlanks).Enti reRow.Delete
End Sub

I need it to do it, the other way around. Delete all rows, where the cell
in column C IS NOT empty. But there is no xlCellType for "Nonblank". So
how do I best do what I want.

Jan




Norman Jones

Deleting non empty rows
 
Hi Jan,

I forgot to extend to the entire row:

Public Sub Tester()
On Error Resume Next
With Range("C:C")
.SpecialCells(xlCellTypeConstants). _
EntireRow.Delete
.SpecialCells(xlCellTypeFormulas). _
EntireRow.Delete

On Error GoTo 0
End With

End Sub


---
Regards,
Norman



"Norman Jones" wrote in message
...
Hi Jan,

Try:

Sub Tester()
On Error Resume Next
With Range("C:C")
.SpecialCells(xlCellTypeConstants).Delete
.SpecialCells(xlCellTypeFormulas).Delete

On Error GoTo 0
End With

End Sub

---
Regards,
Norman


"Jan Kronsell" wrote in message
...
This code deletes the row, if the cell in column C IS empty.

Sub SletBlank()
On Error Resume Next
Columns("C:C").SpecialCells(xlCellTypeBlanks).Enti reRow.Delete
End Sub

I need it to do it, the other way around. Delete all rows, where the cell
in column C IS NOT empty. But there is no xlCellType for "Nonblank". So
how do I best do what I want.

Jan






Jan Kronsell

Deleting non empty rows
 
Hi Norman
Thank you. Your code deletes the contents of the cells, but changing it to


.SpecialCells(xlCellTypeConstants).EntireRow.Delet e

and so on did the trick.

Jan

"Norman Jones" skrev i en meddelelse
...
Hi Jan,

Try:

Sub Tester()
On Error Resume Next
With Range("C:C")
.SpecialCells(xlCellTypeConstants).Delete
.SpecialCells(xlCellTypeFormulas).Delete

On Error GoTo 0
End With

End Sub

---
Regards,
Norman


"Jan Kronsell" wrote in message
...
This code deletes the row, if the cell in column C IS empty.

Sub SletBlank()
On Error Resume Next
Columns("C:C").SpecialCells(xlCellTypeBlanks).Enti reRow.Delete
End Sub

I need it to do it, the other way around. Delete all rows, where the cell
in column C IS NOT empty. But there is no xlCellType for "Nonblank". So
how do I best do what I want.

Jan







All times are GMT +1. The time now is 10:38 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com