View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default how to run through a table an delete the empty cells?

Note that you need to loop from the highest row to the lowest row:

Sub DelteValues()
x = 25 'for example
For i = x To 1 Step -1
If Cells(i, 1).Value = "" Then
Cells(i, 1).Resize(1, 2).Delete Shift:=xlShiftUp
End If
Next
End Sub

--
Regards,
Tom Ogilvy

"desmondleow" wrote in message
...
Thanks Klaus!

Is there any way to just delete cells from A:B and shift it up to close
up the gap? I cannot delete the whole row because I have data from
columns C onwards.

Would appreciate your assistance! Thanks!


---
Message posted from http://www.ExcelForum.com/