+ Reply to Thread
Results 1 to 6 of 6

Selection.Delete Shift:=xlToLeft (what's the meaning of this?)

  1. #1
    markx
    Guest

    Selection.Delete Shift:=xlToLeft (what's the meaning of this?)

    Hello,

    Could someone explain to me what is the meaning of the VBA expression:
    Selection.Delete Shift:=xlToLeft

    Intuitively, I would suppose that it should delete the selection, but why
    there is this "Shift" part coming after?

    The whole part of the code I try to analyze goes like this (and it looks
    like a big garbage for me):

    (...)
    Range("A3").Select
    Range(Selection, Selection.End(xlToRight)).Select
    Range(Selection, Selection.End(xlDown)).Select
    Selection.Copy
    Sheets("Confirmations").Select
    Range("BA22").Select
    Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:=
    _
    False, Transpose:=False
    Columns("BA:BD").Select
    Application.CutCopyMode = False
    Selection.Delete Shift:=xlToLeft
    Columns("BC:BD").Select
    Selection.Delete Shift:=xlToLeft
    Columns("BD:BF").Select
    Selection.Delete Shift:=xlToLeft
    Columns("BE:BZ").Select
    Selection.Delete Shift:=xlToLeft
    Range("BA22:BD55").Select
    Selection.Copy
    Range("A22").Select
    ActiveSheet.Paste
    (...)

    In particular, I can't see what is the goal of selecting first BA:BD, then
    BC:BD, then BD:BF and finally BE:BZ...
    Is it me that don't understand something or the code should be written
    differently? (hint: it's still functionning correctly and it is not deleting
    the data pasted in BA22 (lines 4-8 of the code)).

    Many thanks for any explanations!
    Mark





  2. #2
    Otto Moehrbach
    Guest

    Re: Selection.Delete Shift:=xlToLeft (what's the meaning of this?)

    The line that selects the columns does just that. The line that deletes the
    selection deletes the selected columns. The shift to the left part simply
    shifts the remaining columns to the left. That code is not necessary since
    the shift to the left is the default. Note that if you delete a column, the
    column to the right will move left and occupy the space where the deleted
    column was. The new column will also take the column letter of the deleted
    column. Perhaps that is where you are confused. In other words, if the
    sheet is blank and you delete a column or group of columns, you will not see
    any change at all.
    Exactly what is that you want this code to do? HTH Otto
    "markx" <[email protected]> wrote in message
    news:[email protected]...
    > Hello,
    >
    > Could someone explain to me what is the meaning of the VBA expression:
    > Selection.Delete Shift:=xlToLeft
    >
    > Intuitively, I would suppose that it should delete the selection, but why
    > there is this "Shift" part coming after?
    >
    > The whole part of the code I try to analyze goes like this (and it looks
    > like a big garbage for me):
    >
    > (...)
    > Range("A3").Select
    > Range(Selection, Selection.End(xlToRight)).Select
    > Range(Selection, Selection.End(xlDown)).Select
    > Selection.Copy
    > Sheets("Confirmations").Select
    > Range("BA22").Select
    > Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:=
    > _
    > False, Transpose:=False
    > Columns("BA:BD").Select
    > Application.CutCopyMode = False
    > Selection.Delete Shift:=xlToLeft
    > Columns("BC:BD").Select
    > Selection.Delete Shift:=xlToLeft
    > Columns("BD:BF").Select
    > Selection.Delete Shift:=xlToLeft
    > Columns("BE:BZ").Select
    > Selection.Delete Shift:=xlToLeft
    > Range("BA22:BD55").Select
    > Selection.Copy
    > Range("A22").Select
    > ActiveSheet.Paste
    > (...)
    >
    > In particular, I can't see what is the goal of selecting first BA:BD, then
    > BC:BD, then BD:BF and finally BE:BZ...
    > Is it me that don't understand something or the code should be written
    > differently? (hint: it's still functionning correctly and it is not
    > deleting the data pasted in BA22 (lines 4-8 of the code)).
    >
    > Many thanks for any explanations!
    > Mark
    >
    >
    >
    >




  3. #3
    DaveO
    Guest

    RE: Selection.Delete Shift:=xlToLeft (what's the meaning of this?)

    If you delete a selection of cells normally, if offers you the chance to
    shift the cells up or to the left or the entire row or column.

    The Shift:=xlLeft means it uses the Shift Cells Left option.

    HTH.

    "markx" wrote:

    > Hello,
    >
    > Could someone explain to me what is the meaning of the VBA expression:
    > Selection.Delete Shift:=xlToLeft
    >
    > Intuitively, I would suppose that it should delete the selection, but why
    > there is this "Shift" part coming after?
    >
    > The whole part of the code I try to analyze goes like this (and it looks
    > like a big garbage for me):
    >
    > (...)
    > Range("A3").Select
    > Range(Selection, Selection.End(xlToRight)).Select
    > Range(Selection, Selection.End(xlDown)).Select
    > Selection.Copy
    > Sheets("Confirmations").Select
    > Range("BA22").Select
    > Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:=
    > _
    > False, Transpose:=False
    > Columns("BA:BD").Select
    > Application.CutCopyMode = False
    > Selection.Delete Shift:=xlToLeft
    > Columns("BC:BD").Select
    > Selection.Delete Shift:=xlToLeft
    > Columns("BD:BF").Select
    > Selection.Delete Shift:=xlToLeft
    > Columns("BE:BZ").Select
    > Selection.Delete Shift:=xlToLeft
    > Range("BA22:BD55").Select
    > Selection.Copy
    > Range("A22").Select
    > ActiveSheet.Paste
    > (...)
    >
    > In particular, I can't see what is the goal of selecting first BA:BD, then
    > BC:BD, then BD:BF and finally BE:BZ...
    > Is it me that don't understand something or the code should be written
    > differently? (hint: it's still functionning correctly and it is not deleting
    > the data pasted in BA22 (lines 4-8 of the code)).
    >
    > Many thanks for any explanations!
    > Mark
    >
    >
    >
    >
    >


  4. #4
    markx
    Guest

    Re: Selection.Delete Shift:=xlToLeft (what's the meaning of this?)

    Thanks to you both!
    Now I understand much better this part of code...
    Have a nice day!

    "DaveO" <[email protected]> wrote in message
    news:[email protected]...
    > If you delete a selection of cells normally, if offers you the chance to
    > shift the cells up or to the left or the entire row or column.
    >
    > The Shift:=xlLeft means it uses the Shift Cells Left option.
    >
    > HTH.
    >
    > "markx" wrote:
    >
    >> Hello,
    >>
    >> Could someone explain to me what is the meaning of the VBA expression:
    >> Selection.Delete Shift:=xlToLeft
    >>
    >> Intuitively, I would suppose that it should delete the selection, but why
    >> there is this "Shift" part coming after?
    >>
    >> The whole part of the code I try to analyze goes like this (and it looks
    >> like a big garbage for me):
    >>
    >> (...)
    >> Range("A3").Select
    >> Range(Selection, Selection.End(xlToRight)).Select
    >> Range(Selection, Selection.End(xlDown)).Select
    >> Selection.Copy
    >> Sheets("Confirmations").Select
    >> Range("BA22").Select
    >> Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone,
    >> SkipBlanks:=
    >> _
    >> False, Transpose:=False
    >> Columns("BA:BD").Select
    >> Application.CutCopyMode = False
    >> Selection.Delete Shift:=xlToLeft
    >> Columns("BC:BD").Select
    >> Selection.Delete Shift:=xlToLeft
    >> Columns("BD:BF").Select
    >> Selection.Delete Shift:=xlToLeft
    >> Columns("BE:BZ").Select
    >> Selection.Delete Shift:=xlToLeft
    >> Range("BA22:BD55").Select
    >> Selection.Copy
    >> Range("A22").Select
    >> ActiveSheet.Paste
    >> (...)
    >>
    >> In particular, I can't see what is the goal of selecting first BA:BD,
    >> then
    >> BC:BD, then BD:BF and finally BE:BZ...
    >> Is it me that don't understand something or the code should be written
    >> differently? (hint: it's still functionning correctly and it is not
    >> deleting
    >> the data pasted in BA22 (lines 4-8 of the code)).
    >>
    >> Many thanks for any explanations!
    >> Mark
    >>
    >>
    >>
    >>
    >>




  5. #5
    markx
    Guest

    Re: Selection.Delete Shift:=xlToLeft (what's the meaning of this?)

    Thanks to you both!
    Now I understand much better this part of code...
    Have a nice day!

    "DaveO" <[email protected]> wrote in message
    news:[email protected]...
    > If you delete a selection of cells normally, if offers you the chance to
    > shift the cells up or to the left or the entire row or column.
    >
    > The Shift:=xlLeft means it uses the Shift Cells Left option.
    >
    > HTH.
    >
    > "markx" wrote:
    >
    >> Hello,
    >>
    >> Could someone explain to me what is the meaning of the VBA expression:
    >> Selection.Delete Shift:=xlToLeft
    >>
    >> Intuitively, I would suppose that it should delete the selection, but why
    >> there is this "Shift" part coming after?
    >>
    >> The whole part of the code I try to analyze goes like this (and it looks
    >> like a big garbage for me):
    >>
    >> (...)
    >> Range("A3").Select
    >> Range(Selection, Selection.End(xlToRight)).Select
    >> Range(Selection, Selection.End(xlDown)).Select
    >> Selection.Copy
    >> Sheets("Confirmations").Select
    >> Range("BA22").Select
    >> Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone,
    >> SkipBlanks:=
    >> _
    >> False, Transpose:=False
    >> Columns("BA:BD").Select
    >> Application.CutCopyMode = False
    >> Selection.Delete Shift:=xlToLeft
    >> Columns("BC:BD").Select
    >> Selection.Delete Shift:=xlToLeft
    >> Columns("BD:BF").Select
    >> Selection.Delete Shift:=xlToLeft
    >> Columns("BE:BZ").Select
    >> Selection.Delete Shift:=xlToLeft
    >> Range("BA22:BD55").Select
    >> Selection.Copy
    >> Range("A22").Select
    >> ActiveSheet.Paste
    >> (...)
    >>
    >> In particular, I can't see what is the goal of selecting first BA:BD,
    >> then
    >> BC:BD, then BD:BF and finally BE:BZ...
    >> Is it me that don't understand something or the code should be written
    >> differently? (hint: it's still functionning correctly and it is not
    >> deleting
    >> the data pasted in BA22 (lines 4-8 of the code)).
    >>
    >> Many thanks for any explanations!
    >> Mark
    >>
    >>
    >>
    >>
    >>




  6. #6
    markx
    Guest

    Re: Selection.Delete Shift:=xlToLeft (what's the meaning of this?)

    Thanks to you both!
    Now I understand much better this part of code...
    Have a nice day!

    "DaveO" <[email protected]> wrote in message
    news:[email protected]...
    > If you delete a selection of cells normally, if offers you the chance to
    > shift the cells up or to the left or the entire row or column.
    >
    > The Shift:=xlLeft means it uses the Shift Cells Left option.
    >
    > HTH.
    >
    > "markx" wrote:
    >
    >> Hello,
    >>
    >> Could someone explain to me what is the meaning of the VBA expression:
    >> Selection.Delete Shift:=xlToLeft
    >>
    >> Intuitively, I would suppose that it should delete the selection, but why
    >> there is this "Shift" part coming after?
    >>
    >> The whole part of the code I try to analyze goes like this (and it looks
    >> like a big garbage for me):
    >>
    >> (...)
    >> Range("A3").Select
    >> Range(Selection, Selection.End(xlToRight)).Select
    >> Range(Selection, Selection.End(xlDown)).Select
    >> Selection.Copy
    >> Sheets("Confirmations").Select
    >> Range("BA22").Select
    >> Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone,
    >> SkipBlanks:=
    >> _
    >> False, Transpose:=False
    >> Columns("BA:BD").Select
    >> Application.CutCopyMode = False
    >> Selection.Delete Shift:=xlToLeft
    >> Columns("BC:BD").Select
    >> Selection.Delete Shift:=xlToLeft
    >> Columns("BD:BF").Select
    >> Selection.Delete Shift:=xlToLeft
    >> Columns("BE:BZ").Select
    >> Selection.Delete Shift:=xlToLeft
    >> Range("BA22:BD55").Select
    >> Selection.Copy
    >> Range("A22").Select
    >> ActiveSheet.Paste
    >> (...)
    >>
    >> In particular, I can't see what is the goal of selecting first BA:BD,
    >> then
    >> BC:BD, then BD:BF and finally BE:BZ...
    >> Is it me that don't understand something or the code should be written
    >> differently? (hint: it's still functionning correctly and it is not
    >> deleting
    >> the data pasted in BA22 (lines 4-8 of the code)).
    >>
    >> Many thanks for any explanations!
    >> Mark
    >>
    >>
    >>
    >>
    >>




+ 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