+ Reply to Thread
Results 1 to 5 of 5

Delete Blanks and Shift Cells Left with Current Selection

  1. #1
    Registered User
    Join Date
    10-08-2012
    Location
    Chico, California
    MS-Off Ver
    Excel 2007
    Posts
    7

    Delete Blanks and Shift Cells Left with Current Selection

    I have searched all over the forums for this. I have tried to select the range manually and use the 'Selection.' code below, which works just fine for a small amount of data, but does not work with several hundred cells selected. I also tried the 'Range' code below by manually defining the range of cells, but that did not work either.

    Please Login or Register  to view this content.
    I would be okay with a working macro that performed the blank cell delete and shift left functions with my current selection, but having a more dynamic macro would be even better.

    Eventually I would like to create a macro that will count the number of rows and columns in which data is present to determine the range, rather than selecting it manually or modifying the macro for a preset range. That would make it easy to bind to a button so that I can copy various table sizes into the sheet and compress the data based on the number of rows and columns in which data is present.

    I have attached small example of what I am trying to do.
    Attached Files Attached Files

  2. #2
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Delete Blanks and Shift Cells Left with Current Selection

    This worked with your sample:

    Please Login or Register  to view this content.
    If I've helped you, please consider adding to my reputation - just click on the liitle star at the left.

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~(Pride has no aftertaste.)

    You can't do one thing. XLAdept

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~aka Orrin

  3. #3
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Delete Blanks and Shift Cells Left with Current Selection

    Another option

    Please Login or Register  to view this content.

  4. #4
    Registered User
    Join Date
    10-08-2012
    Location
    Chico, California
    MS-Off Ver
    Excel 2007
    Posts
    7

    Re: Delete Blanks and Shift Cells Left with Current Selection

    Thanks both of you. I had some cells with blank text strings in them rather than actually being blank, which was causing the original code to fail.

    AB33 - That code is excellent. I have used it to program a button for my sheet. Thanks a bunch!

  5. #5
    Registered User
    Join Date
    12-05-2012
    Location
    Pera, Malaysia
    MS-Off Ver
    Excel 2007
    Posts
    1

    Re: Delete Blanks and Shift Cells Left with Current Selection

    Thank you very much. It worked fine.

+ 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