Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 12
Default xlCellTypeBlanks, but no blank cells to delete

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!

  #2   Report Post  
Posted to microsoft.public.excel.programming
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!


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default xlCellTypeBlanks, but no blank cells to delete

Count before Selecting:

If Selection.SpecialCells(xlCellTypeBlanks).Count0 then
Selection.SpecialCells(xlCellTypeBlanks).Select
Selection.Delete Shift=xlToLeft
End If
--
Gary''s Student - gsnu2007k


"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!


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 22,906
Default xlCellTypeBlanks, but no blank cells to delete

Sub Shift_Blanks()
Dim c As Range
With Selection
Do
Set c = .Find("", LookIn:=xlValues, lookat:=xlWhole, _
MatchCase:=False)
If c Is Nothing Then Exit Do
c.Delete shift:=xlToLeft
Loop
End With

'do the rest of your stuff

End Sub


Gord Dibben MS Excel MVP

On Tue, 16 Dec 2008 18:31:43 -0600, 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!


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default xlCellTypeBlanks, but no blank cells to delete

Many thanks to all who posted with replies. All solutions accomplished the job,
showing there is more than one way to skin a cat. Thanks again!




?B?QmFyYiBSZWluaGFyZHQ=?=
wrote:
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!



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
how to delete blank cells between those with entries dumchik Excel Worksheet Functions 1 December 8th 08 05:13 AM
How do I Delete blank cells in a row Andy in Edinburgh[_2_] Excel Discussion (Misc queries) 3 September 5th 08 05:46 PM
.SpecialCells(xlCellTypeBlanks).EntireRow.Delete ward376 Excel Programming 4 April 29th 08 08:38 PM
Using a function to delete blank cells Carter Devereaux Excel Worksheet Functions 2 September 1st 07 03:40 PM
Macro to delete all blank cells Brian Excel Programming 2 December 15th 05 12:26 AM


All times are GMT +1. The time now is 03:46 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"