Thread: Deleting a row
View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default Deleting a row

That will put a space in the cell, but not what I am talking about.

--
Regards,
Tom Ogilvy

"Don Guillett" wrote in message
...
or accidentally touching the space bar will do it

--
Don Guillett
SalesAid Software

"Tom Ogilvy" wrote in message
...
I don't follow exactly what you did, but if you put
=""
in a cell, then do edit=copy and Edit=paste Special and select values,
the
cell will have a len of zero but will not be empty.

Therefore SpecialCells(xlBlanks) will not pick it up since it isn't

blank.

--
Regards,
Tom Ogilvy




"Mike Fogleman" wrote in message
...
Tom, oddly enough, in my test sheet if I inserted 2 spaces into the

Blank
cells, then did Trim function and paste special values, Don's code

still
did
not work, telling me the cells are still not truly blank! Only when I
Cleared Contents did Don's code work. Hmmm.

Mike F

"Don Guillett" wrote in message
...
Agreed.


--
Don Guillett
SalesAid Software

"Tom Ogilvy" wrote in message
...


Sub deleteRowsWithBlanksInC()
For i = Cells(Rows.Count, "c").End(xlUp).Row To 2 Step -1
If len(trim(Cells(i, "c"))) = 0 Then Rows(i).Delete
Next i
End Sub

would be more robust.

--
Regards,
Tom Ogilvy


"Don Guillett" wrote in message
...
I think OP said "blank" so it's unlikely there would be more than

one
space.

--
Don Guillett
SalesAid Software

"Mike Fogleman" wrote in message
...
Don, this will work if there is only one space in the cell. What

if
there
are two or more. My code, although not as compact as yours, will
compare
the number of spaces to the length of the text, and if they are

equal,
no
matter how many there are, it will delete the row.
Sound reasonable? If the length is 0 then it will immediately
delete
the
row without testing for spaces.
Mike F
"Don Guillett" wrote in message
...
try this to get spaces and blanks
Sub deleteallblanks()
For i = Cells(Rows.Count, "c").End(xlUp).Row To 2 Step -1
If Cells(i, "c") = " " Or Cells(i, "c") = "" Then Rows(i).Delete
Next i
End Sub

--
Don Guillett
SalesAid Software

"Neal" wrote in message
...
I tried it and nothing happened!

"Don Guillett" wrote:

try
Sub RowBeGone()
Columns("c").SpecialCells(xlCellTypeBlanks).Entire Row.Delete
End Sub

--
Don Guillett
SalesAid Software

"Neal" wrote in message
...
How would I write the code to delete a row depending on if a
certain
cell
is
blank?
If e1 is blank delete row 1 and so on.

range("C").Select
do
row.Delete Shift:=xlUp
loop until isempty(activecell<" ")

Or something like this? I would greatly appreciate the help.
Thanks
Neal.