View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Barb Reinhardt Barb Reinhardt is offline
external usenet poster
 
Posts: 3,355
Default xlCellTypeBlanks, but no blank cells to delete

How about something like this

Dim myRange as range
Set myRange = Nothing
on error resume next
set myrange = Selection.SpecialCells(xlCellTypeBlanks)
on error goto 0
if not myrange is nothing then
myrange.Delete Shift=xlToLeft
end if
--
HTH,
Barb Reinhardt

If this post was helpful to you, please click YES below.



"Melvin Purvis" wrote:

As part of importing a csv file, I have to correct some errors in the data.
What I had before worked OK, but this weeks version of the csv made my code
bomb out.

What I'm doing is deleting some blank cells. This week, there were no blank
cells in the csv!

This is what I have now:

Selection.SpecialCells(xlCellTypeBlanks).Select
Selection.Delete Shift=xlToLeft

What I need is something to do this:
Selection.SpecialCells(xlCellTypeBlanks).Select
If there are no blank cells, jump past the next line
Selection.Delete Shift=xlToLeft
to here

HELP PLEASE!