LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 312
Default Delete blank calls in row, shifting left

Hi everyone. I am looking for a way for VBA to look at a row, identify
blank cells, and remove them, therefore shifting all populated cells to the
left so data is in a continuous line. The code below does that for me. But
since it "deletes" the cells, the format and data validation in each cell
that is deleted goes with it. So, I have to reinitiate the validation and
the format. Is there an easier way to do this? Ideally, not "delete" the
cell, but simply move the contents of populated cells to the left so as to
eliminate the blank cells? Thanks!


Sub Shift_left()
Dim Rng As Range

'Remove blanks
Set Rng = Worksheets("HR DB").Range("L5:BI" &
Range("B65536").End(xlUp).Row)
Rng.SpecialCells(xlCellTypeBlanks).Delete xlToLeft
'ActiveSheet.Cells.SpecialCells(xlCellTypeBlanks). Delete xlToLeft

'Reinitiate Data Validation for PO's
Worksheets("HR DB").Range("L5:BI" & Worksheets("HR
DB").Range("B65536").End(xlUp).Row).Select
With Selection.Validation
.Delete
.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:=
_
xlBetween, Formula1:="=POList2"
.IgnoreBlank = True
.InCellDropdown = True
.InputTitle = ""
.ErrorTitle = ""
.InputMessage = ""
.ErrorMessage = ""
.ShowInput = True
.ShowError = True
End With
End Sub


 
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
shifting of data to fill into blank cells tikchye_oldLearner57 Excel Discussion (Misc queries) 6 April 11th 07 11:02 PM
how to delete cells without shifting and rows/columns Jeff Excel Programming 9 September 24th 04 09:10 PM
Delete a blank cell and shift left jrb Excel Programming 8 February 28th 04 12:20 PM
Deleting blanks and shifting left - cont. jrb[_4_] Excel Programming 3 February 27th 04 02:23 AM
Delete a blank cell and shift left jrb[_2_] Excel Programming 1 February 26th 04 09:52 PM


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