Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
jrb jrb is offline
external usenet poster
 
Posts: 1
Default Delete a blank cell and shift left

I need to figure out a way to take a range, and for each blank cell i
that range delete it and shuft it left. Is there an easy way to d
this?


Thanks JR

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

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 66
Default Delete a blank cell and shift left

Hi JRB

Here you go- have fun! =

------------------------------------------------------------
Sub DelBlanks(

Dim Blanks As Rang

Set Blanks = Cells.SpecialCells(xlCellTypeBlanks

Blanks.Delete shift:=xlToLef

End Su
------------------------------------------------------------

SuperJas.
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 634
Default Delete a blank cell and shift left

If you didn't need it in code, then just select the range, do Edit / Go To /
Special / Blank cells / then Edit / Delete / Shift Cells left.

--
Regards
Ken....................... Microsoft MVP - Excel
Sys Spec - Win XP Pro / XL 00/02/03

----------------------------------------------------------------------------
It's easier to beg forgiveness than ask permission :-)
----------------------------------------------------------------------------



"jrb " wrote in message
...
I need to figure out a way to take a range, and for each blank cell in
that range delete it and shuft it left. Is there an easy way to do
this?


Thanks JRB


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



---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.595 / Virus Database: 378 - Release Date: 25/02/2004


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Delete a blank cell and shift left

Ken,

Thanks for your suggestion but when I set a range, select goto
special, blanks it doesn't select any of the blank cells. Any ideas

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

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 634
Default Delete a blank cell and shift left

Then they aren't really blank. This means that the code you were given by the
others also won't work. If you are seeing 'blank' cells, but for example those
cells are really the results of formula that return blanks, eg

=IF(X<1,"","abc") which if X doesn't equal 1 will appear to be a blank cell.
The cell however is not really blank, and so you cannot use the special cells
method to do what you want. Perhaps also you actually have spaces in there. If
so then what you can do is to use a piece of code to delete what appear to be
blank rows by trimming the cells and deleting any that have a length of 0, eg:-

Sub DelBlankLookingCells()

Dim Rng As Range
Dim Cel As Range
Dim DelRng As Range
Set DelRng = Nothing
Set Rng = ActiveSheet.UsedRange

For Each Cel In Rng
If Len(Trim(Cel.Value)) = 0 Then
If DelRng Is Nothing Then
Set DelRng = Cel
Else
Set DelRng = Union(DelRng, Cel)
End If
End If
Next
If Not DelRng Is Nothing Then
DelRng.Delete Shift:=xlToLeft
End If
End Sub

--
Regards
Ken....................... Microsoft MVP - Excel
Sys Spec - Win XP Pro / XL 00/02/03

----------------------------------------------------------------------------
It's easier to beg forgiveness than ask permission :-)
----------------------------------------------------------------------------



"jrb " wrote in message
...
Ken,

Thanks for your suggestion but when I set a range, select goto,
special, blanks it doesn't select any of the blank cells. Any ideas.


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



---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.595 / Virus Database: 378 - Release Date: 25/02/2004




  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 634
Default Delete a blank cell and shift left

blank rows by trimming

I meant cells, not rows :-(

--
Regards
Ken....................... Microsoft MVP - Excel
Sys Spec - Win XP Pro / XL 00/02/03

----------------------------------------------------------------------------
It's easier to beg forgiveness than ask permission :-)
----------------------------------------------------------------------------



"Ken Wright" wrote in message
...
Then they aren't really blank. This means that the code you were given by the
others also won't work. If you are seeing 'blank' cells, but for example

those
cells are really the results of formula that return blanks, eg

=IF(X<1,"","abc") which if X doesn't equal 1 will appear to be a blank cell.
The cell however is not really blank, and so you cannot use the special cells
method to do what you want. Perhaps also you actually have spaces in there.

If
so then what you can do is to use a piece of code to delete what appear to be
blank rows by trimming the cells and deleting any that have a length of 0,

eg:-

Sub DelBlankLookingCells()

Dim Rng As Range
Dim Cel As Range
Dim DelRng As Range
Set DelRng = Nothing
Set Rng = ActiveSheet.UsedRange

For Each Cel In Rng
If Len(Trim(Cel.Value)) = 0 Then
If DelRng Is Nothing Then
Set DelRng = Cel
Else
Set DelRng = Union(DelRng, Cel)
End If
End If
Next
If Not DelRng Is Nothing Then
DelRng.Delete Shift:=xlToLeft
End If
End Sub

--
Regards
Ken....................... Microsoft MVP - Excel
Sys Spec - Win XP Pro / XL 00/02/03

----------------------------------------------------------------------------
It's easier to beg forgiveness than ask permission :-)
----------------------------------------------------------------------------



"jrb " wrote in message
...
Ken,

Thanks for your suggestion but when I set a range, select goto,
special, blanks it doesn't select any of the blank cells. Any ideas.


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



---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.595 / Virus Database: 378 - Release Date: 25/02/2004




---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.595 / Virus Database: 378 - Release Date: 25/02/2004


  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Delete a blank cell and shift left

Ken,

Is it possible for me to send you a copy of this spreadsheet I a
working on. I have one other item that I am trying to accomplish, bu
it will be difficult to explain without you seeing the sheet.

Jef

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

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
Auto-ID and Delete/left shift cells when a cell contains text? IndyToothDoc Excel Discussion (Misc queries) 0 June 29th 09 06:06 PM
Delete 4 to 5 digits from left in a cell Bob Phillips Excel Discussion (Misc queries) 2 April 27th 06 08:19 PM
Delete 4 to 5 digits from left in a cell Peo Sjoblom Excel Discussion (Misc queries) 3 April 27th 06 08:10 PM
Delete 4 to 5 digits from left in a cell Toppers Excel Discussion (Misc queries) 0 April 27th 06 07:33 PM
delete coumns - shift non-blank cells message omb researcher Excel Discussion (Misc queries) 2 September 26th 05 11:07 PM


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