Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Delete entire row if A1,2,3... is empty

Hey there.
I have this piece of code:

Private Sub CommandButton1_Click()
Dim i As Double
i = 1

For i = 1 To 5850
Cells(i, 1).Select
If ActiveCell.Value = Empty Then ActiveCell.EntireRow.Delete
i = i + 1
Next

End Sub

I want this:
In range A1:A5850 if cells in the first column (A) are empty then delete
entire row.
Exmple:
A
1 5
2
3 3
4 1

It should only delete the 2 entire row.
Can anyone help?
With that piece of code i get an I/O error and no rows deleted...
Thanks,



  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Delete entire row if A1,2,3... is empty

Try this
http://www.rondebruin.nl/delete.htm

One of this lines you can use

ElseIf .Cells(Lrow, "A").Value = "" Then .Rows(Lrow).Delete
'This will delete each row if the cell is empty or have a formula that evaluates to "" ElseIf IsEmpty(.Cells(Lrow,
"A").Value) Then .Rows(Lrow).Delete
'This will delete the row if the cell is empty
--
Regards Ron de Bruin
(Win XP Pro SP-1 XL2000-2003)
www.rondebruin.nl



"cimento cola" wrote in message ...
Hey there.
I have this piece of code:

Private Sub CommandButton1_Click()
Dim i As Double
i = 1

For i = 1 To 5850
Cells(i, 1).Select
If ActiveCell.Value = Empty Then ActiveCell.EntireRow.Delete
i = i + 1
Next

End Sub

I want this:
In range A1:A5850 if cells in the first column (A) are empty then delete
entire row.
Exmple:
A
1 5
2
3 3
4 1

It should only delete the 2 entire row.
Can anyone help?
With that piece of code i get an I/O error and no rows deleted...
Thanks,





  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Delete entire row if A1,2,3... is empty

This is better

ElseIf .Cells(Lrow, "A").Value = "" Then .Rows(Lrow).Delete
'This will delete each row if the cell is empty or have a formula that evaluates to ""

ElseIf IsEmpty(.Cells(Lrow, "A").Value) Then .Rows(Lrow).Delete
'This will delete the row if the cell is empty


--
Regards Ron de Bruin
(Win XP Pro SP-1 XL2000-2003)
www.rondebruin.nl



"Ron de Bruin" wrote in message ...
Try this
http://www.rondebruin.nl/delete.htm

One of this lines you can use

ElseIf .Cells(Lrow, "A").Value = "" Then .Rows(Lrow).Delete
'This will delete each row if the cell is empty or have a formula that evaluates to "" ElseIf IsEmpty(.Cells(Lrow,
"A").Value) Then .Rows(Lrow).Delete
'This will delete the row if the cell is empty
--
Regards Ron de Bruin
(Win XP Pro SP-1 XL2000-2003)
www.rondebruin.nl



"cimento cola" wrote in message ...
Hey there.
I have this piece of code:

Private Sub CommandButton1_Click()
Dim i As Double
i = 1

For i = 1 To 5850
Cells(i, 1).Select
If ActiveCell.Value = Empty Then ActiveCell.EntireRow.Delete
i = i + 1
Next

End Sub

I want this:
In range A1:A5850 if cells in the first column (A) are empty then delete
entire row.
Exmple:
A
1 5
2
3 3
4 1

It should only delete the 2 entire row.
Can anyone help?
With that piece of code i get an I/O error and no rows deleted...
Thanks,







  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 26
Default Delete entire row if A1,2,3... is empty

If there happened to be 2 blank spaces in a row, would it not skip the 2nd one?
The counting backwards seems to be the way to go.
"Mark Rosenkrantz" wrote in message ...
Cimento;

For i = 1 To 5850
Cells(i, 1).Select
If IsEmpty(ActiveCell.Value) Then ActiveCell.EntireRow.Delete
Next i


Mark.

Succes;

More Excel ? www.rosenkrantz.nl or
---------------------------------------------------------------------


"cimento cola" wrote in message
...
Hey there.
I have this piece of code:

Private Sub CommandButton1_Click()
Dim i As Double
i = 1

For i = 1 To 5850
Cells(i, 1).Select
If ActiveCell.Value = Empty Then ActiveCell.EntireRow.Delete
i = i + 1
Next

End Sub

I want this:
In range A1:A5850 if cells in the first column (A) are empty then delete
entire row.
Exmple:
A
1 5
2
3 3
4 1

It should only delete the 2 entire row.
Can anyone help?
With that piece of code i get an I/O error and no rows deleted...
Thanks,





Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to SUM entire column, but only when adjacent cell is not empty SteveDJ Excel Worksheet Functions 3 May 7th 10 09:16 PM
Delete an entire row One-Leg Excel Discussion (Misc queries) 13 November 11th 08 08:27 PM
Delete entire row if David T Excel Discussion (Misc queries) 2 December 6th 06 10:14 PM
Delete Entire Row. Sam Excel Programming 5 December 21st 03 05:56 AM
Is entire row empty? soylent green Excel Programming 10 November 13th 03 06:44 PM


All times are GMT +1. The time now is 04:26 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"