Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 89
Default Deleting Cells

Hello,
I have a column of numbers with a few cells being blank. I am using the
following code to delete the blank cells: and shift the numbers up.

LR = cells(1,1).end(xldown).row
for i = 1 to lr
if isempty(cells(i,1))=true then
cells(i,1).delete shift:=xlup
i = i -1
end if
next i

I get in a loop because of the i = 1 -1. I need that to ensure there are
not two blank cells together.

Any ideas.

Thanks

Bill


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default Deleting Cells

Hi Bill,

With your existing method, you should start at the bottom and work upwards.

As another approach, try:

On Error Resume Next
Columns("A").SpecialCells(xlBlanks).Delete shift:=xlUp
On Error GoTo 0


---
Regards,
Norman



"Bill" wrote in message
ink.net...
Hello,
I have a column of numbers with a few cells being blank. I am using the
following code to delete the blank cells: and shift the numbers up.

LR = cells(1,1).end(xldown).row
for i = 1 to lr
if isempty(cells(i,1))=true then
cells(i,1).delete shift:=xlup
i = i -1
end if
next i

I get in a loop because of the i = 1 -1. I need that to ensure there are
not two blank cells together.

Any ideas.

Thanks

Bill



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,119
Default Deleting Cells

It is a little easier than all of that... Try this

Range("A:A").SpecialCells(xlCellTypeBlanks).Delete xlShiftUp
--
HTH...

Jim Thomlinson


"Bill" wrote:

Hello,
I have a column of numbers with a few cells being blank. I am using the
following code to delete the blank cells: and shift the numbers up.

LR = cells(1,1).end(xldown).row
for i = 1 to lr
if isempty(cells(i,1))=true then
cells(i,1).delete shift:=xlup
i = i -1
end if
next i

I get in a loop because of the i = 1 -1. I need that to ensure there are
not two blank cells together.

Any ideas.

Thanks

Bill



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
Deleting Cells or Rows of Cells Nelly Excel Discussion (Misc queries) 3 August 22nd 07 11:46 AM
deleting cells JULZ New Users to Excel 1 August 21st 06 04:59 PM
deleting unused cells / getting rid of inactive cells Woody13 Excel Discussion (Misc queries) 3 January 26th 06 09:11 PM
Deleting cells in a row Jeff Wright[_2_] Excel Programming 4 April 17th 05 07:49 AM
Deleting Hyphens or Dashes from multiple cells without deleting the remaining content rmaloy Excel Programming 5 February 9th 04 01:59 AM


All times are GMT +1. The time now is 12:43 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"