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

I've selected A5:D10, then run the following macro:
(The range has multiple blank cells scattered throughout
and I'd like to eliminate the blank cells and pull all to the
leftmost as contiguous cells. One of my rows which only
has a value in D7 doesn't make it over to A7 (it gets moved to only B7..)
Any sugestions?

Sub Macro3()
' Macro3 Macro
' Macro recorded/edited 7/24/2005 by Jim May
Set Rng = Selection
For Each bcell In Rng
If bcell = "" Then
bcell.Delete Shift:=xlToLeft
End If
Next
End Sub



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

Hi Jim,

Try:

Sub Macro3()

Dim rng As Range

Set rng = Selection
On Error Resume Next
Selection.SpecialCells(xlBlanks).Delete Shift:=xlToLeft
On Error GoTo 0

End Sub

---
Regards,
Norman



"Jim May" wrote in message
news:rMOEe.82038$Fv.44627@lakeread01...
I've selected A5:D10, then run the following macro:
(The range has multiple blank cells scattered throughout
and I'd like to eliminate the blank cells and pull all to the
leftmost as contiguous cells. One of my rows which only
has a value in D7 doesn't make it over to A7 (it gets moved to only B7..)
Any sugestions?

Sub Macro3()
' Macro3 Macro
' Macro recorded/edited 7/24/2005 by Jim May
Set Rng = Selection
For Each bcell In Rng
If bcell = "" Then
bcell.Delete Shift:=xlToLeft
End If
Next
End Sub





  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default Code assistance

Hi Jim,

I intended:

Sub Macro3()

Dim rng As Range

Set rng = Selection
On Error Resume Next
rng.SpecialCells(xlBlanks).Delete Shift:=xlToLeft
On Error GoTo 0

End Sub

(Forgot to replace Selection with the range variable)

---
Regards,
Norman



"Norman Jones" wrote in message
...
Hi Jim,

Try:

Sub Macro3()

Dim rng As Range

Set rng = Selection
On Error Resume Next
Selection.SpecialCells(xlBlanks).Delete Shift:=xlToLeft
On Error GoTo 0

End Sub

---
Regards,
Norman



"Jim May" wrote in message
news:rMOEe.82038$Fv.44627@lakeread01...
I've selected A5:D10, then run the following macro:
(The range has multiple blank cells scattered throughout
and I'd like to eliminate the blank cells and pull all to the
leftmost as contiguous cells. One of my rows which only
has a value in D7 doesn't make it over to A7 (it gets moved to only B7..)
Any sugestions?

Sub Macro3()
' Macro3 Macro
' Macro recorded/edited 7/24/2005 by Jim May
Set Rng = Selection
For Each bcell In Rng
If bcell = "" Then
bcell.Delete Shift:=xlToLeft
End If
Next
End Sub







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
Code assistance Jim May Excel Programming 3 May 26th 05 01:11 PM
Assistance with code Please Greg B... Excel Discussion (Misc queries) 8 March 2nd 05 10:55 PM
I need assistance getting VBA code to do the following... SD Excel Programming 1 February 3rd 05 03:17 AM
Code assistance please JMay Excel Programming 3 September 4th 04 05:21 PM
VBA Code Assistance chryo Excel Programming 9 August 7th 04 12:57 AM


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