+ Reply to Thread
Results 1 to 4 of 4

Need inclusive selection expansion VBA with multiple selection (was "xltoleft challenge?")

  1. #1
    Valued Forum Contributor
    Join Date
    11-15-2010
    Location
    Dallas, TX
    MS-Off Ver
    Excel 2003
    Posts
    538

    Need inclusive selection expansion VBA with multiple selection (was "xltoleft challenge?")

    [edit: retitled at request of moderator Winon]

    I'm seeking a variation of
    Range(ActiveCell, ActiveCell.End(xlToLeft)).Select (like control-shift-left arrow)
    but to use when more than a single cell is selected.

    To demonstrate:
    In an empty sheet put a zero (or anything) in B1, B2 and D2
    Go to A1
    Go Control-shift-end (selecting everything through the bottom right, A1:D2)
    (Range(Selection, ActiveCell.SpecialCells(xlLastCell)).Select)

    Now the objective is to simulate Control-Shift-Left arrow.
    If you do this with the keystroke you end up with A1:B2 selected. That's what I want.
    But Range(ActiveCell, ActiveCell.End(xlToLeft)).Select only leaves A1 selected, so what works?

    Maybe Range(selection, selection.End(xlToLeft)).Select
    is a start in the right, um, left direction.
    Chip, if you can read this, you're STILL making the world a better place with your immeasurably valuable gifts. Every week, you continue to help me (and untold numbers of others) tremendously. Practically no alternative outlets can match your effectiveness, even over the vast number of topics you demystify and empower usage of. You were, and still are, amazing.

  2. #2
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,659

    Re: Need inclusive selection expansion VBA with multiple selection (was "xltoleft challeng

    Quote Originally Posted by Oppressed1 View Post
    Go Control-shift-end (selecting everything through the bottom right, A1:D2)
    (Range(Selection, ActiveCell.SpecialCells(xlLastCell)).Select)

    Now the objective is to simulate Control-Shift-Left arrow.
    If you do this with the keystroke you end up with A1:B2 selected. That's what I want.
    If you do your steps while recording a macro, it should give you the code, or am I missing something.

    Please Login or Register  to view this content.
    Surround your VBA code with CODE tags e.g.;
    [CODE]your VBA code here[/CODE]
    The # button in the forum editor will apply CODE tags around your selected text.

  3. #3
    Valued Forum Contributor
    Join Date
    11-15-2010
    Location
    Dallas, TX
    MS-Off Ver
    Excel 2003
    Posts
    538

    Re: Need inclusive selection expansion VBA with multiple selection (was "xltoleft challeng

    Thank you for your always excellent responses. I apologize but in retitling the subject line I inadvertently created a new thread. Use http://www.excelforum.com/excel-prog...ml#post3465943 instead. Sorry.

    As to your answer here (but to respond, please use original thread in above link), on the described scenario, when you do that
    Range(Selection, Selection.End(xlToLeft)).Select
    the selection does not change when I do it, unlike control-shift-arrow. I appreciate the reasonable reminder of the common sense answer of recording and working from that, but it didn't pay off this time.

  4. #4
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,659

    Re: Need inclusive selection expansion VBA with multiple selection (was "xltoleft challeng

    I see. I didn't test the result recorded code. It doesn't act as recorded. I'm not sure why.

    Here's a different method. It works for your example scenario.

    Please Login or Register  to view this content.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] "copy paste" using "=" but its only pulling the first value of the selection?
    By bauerbach in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-07-2012, 02:59 PM
  2. [SOLVED] IF cant find selection of multiple keywords return "text"
    By Eagle75au in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 05-30-2012, 02:52 AM
  3. Macro Assistance Multiple Selection Items and "Blanking Cells"
    By gravel in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 08-31-2011, 09:55 AM
  4. [SOLVED] Changing Selection for the "Center Across Selection" alignment
    By johnandsuzie in forum Excel General
    Replies: 1
    Last Post: 01-18-2006, 12:48 PM
  5. Replies: 4
    Last Post: 04-25-2005, 10:06 AM

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