+ Reply to Thread
Results 1 to 2 of 2

Delete blank calls in row, shifting left

  1. #1
    Steph
    Guest

    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



  2. #2
    Tom Ogilvy
    Guest

    Re: Delete blank calls in row, shifting left

    If that code is doing what you need, why worry. There is no support for
    doing what you want - and working around it would involve more code than
    what you have.

    --
    Regards,
    Tom Ogilvy

    "Steph" <verysmallrox@yahoo.com> wrote in message
    news:u6G6NStZFHA.3572@TK2MSFTNGP12.phx.gbl...
    > 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
    >
    >




+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1