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

I have a VBA procedure that loops through cells collecting information on the contents of cells with values greater than zero.

Sometimes the program will blow up when it reaches a particular cell that appears to be completely empty but which passes as 0 when the program looks at it.

I try to delete the contents of the cell but it still goes through as 0.

Any way to erase a ghost cell like this?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 829
Default Ghost Cells

wrote:
I have a VBA procedure that loops through cells collecting
information on the contents of cells with values greater than zero.
Sometimes the program will blow up when it reaches a particular cell
that appears to be completely empty but which passes as 0 when the
program looks at it. I try to delete the contents of the cell but it
still goes through as 0. Any way to erase a ghost cell like this?


What do you do to "try to delete the contents"?

My guess: the cell value is a null string that might have been
copy-and-pasted-value. So you would do see any evidence of it. But note
that in Excel (and VBA), text is always considered greater than any
numerical value.

To clear the cell:
Range(...).ClearContents
or
Range(...).Clear (contents, formats, etc)

You might also try:
Activesheet.UsedRange

Usually, that resets Excel's idea of the where the last cell of the
worksheet is.

However, keep in mind that if the cell's format has changed -- even from
something back to General -- Excel considers the cell to be used, even
though it might not contain a value.

Finally, if you cannot eliminate the cell from the loop range, change your
test to:

If Range(...) < "" And Range(...) 0 Then
or
If Trim(Range(...)) < "" And Range(...) 0 Then

Of course, it would be more efficient to load Range(...) only once.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 829
Default Ghost Cells

"joeu2004" wrote:
To clear the cell:
Range(...).ClearContents
or
Range(...).Clear (contents, formats, etc)

You might also try:
Activesheet.UsedRange
[...]
change your test to:
If Range(...) < "" And Range(...) 0 Then

or
If Trim(Range(...)) < "" And Range(...) 0 Then


If no one's suggests seem to work, upload an example Excel file to a
file-sharing website, and post the share/public URL in a new response in
this thead. The devil is in the details, often.

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
Ghost in my VLOOKUP WildWill Excel Discussion (Misc queries) 1 October 12th 09 04:28 PM
Ghost Reference pikapika13[_6_] Excel Programming 1 May 30th 06 08:34 PM
Ghost numbers in blank cells scott Excel Worksheet Functions 2 January 5th 06 06:53 PM
Ghost image David Excel Programming 2 April 17th 04 04:41 AM
Add-in causing 'GHOST' cells to be selected jason Excel Programming 1 September 15th 03 11:50 PM


All times are GMT +1. The time now is 08:03 AM.

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"