+ Reply to Thread
Results 1 to 14 of 14

Delete blank cell to the right

  1. #1
    Registered User
    Join Date
    06-28-2010
    Location
    Posen, Poland
    MS-Off Ver
    Excel 2000
    Posts
    46

    Delete blank cell to the right

    Hi,

    The following codes selected range H1:J13 -

    Please Login or Register  to view this content.
    then I want to (remove blank cells, and) shift non-blank cells to the right (range H1:J13);
    below code shift non-blank cells to left:
    Please Login or Register  to view this content.
    How it will look a code to shift cells to the right?

    ps. see the attach
    Attached Images Attached Images
    Last edited by markos97; 07-09-2013 at 03:52 PM.

  2. #2
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Delete blank cell to the right

    Maybe:

    Please Login or Register  to view this content.

  3. #3
    Forum Expert Debraj Roy's Avatar
    Join Date
    09-27-2012
    Location
    New Delhi,India
    MS-Off Ver
    Excel 2013
    Posts
    1,469

    Re: Delete blank cell to the right

    Hi Markos..

    Can you please check, if below code is doing your purpose..

    Please Login or Register  to view this content.
    Regards!
    =DEC2HEX(3563)

    If you like someone's answer, click the star to give them a reputation point for that answer...

  4. #4
    Registered User
    Join Date
    06-28-2010
    Location
    Posen, Poland
    MS-Off Ver
    Excel 2000
    Posts
    46

    Re: Delete blank cell to the right

    thanks Debraj Roy, but this 3 columns is only an example (I have many columns);
    JOHN H. DAVIS, your code works good, but something is wrong, see the results after run your code, looks like... (see the next attach)

    ps. in line
    Please Login or Register  to view this content.
    I change to
    Please Login or Register  to view this content.
    ps. marco doesn't work to more than 3 columns...
    Attached Images Attached Images
    Last edited by markos97; 07-09-2013 at 10:15 AM.

  5. #5
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Delete blank cell to the right

    It looks like you selected 4 columns, the code was for 3 columns.

  6. #6
    Registered User
    Join Date
    06-28-2010
    Location
    Posen, Poland
    MS-Off Ver
    Excel 2000
    Posts
    46

    Re: Delete blank cell to the right

    yes,
    your code works good for this 3 columns
    (but must select only one column - column H:H - to get correct results) - sorry (I select all 3 columns)...

    but... I need a macro to work on more than 3 columns...

  7. #7
    Forum Expert Debraj Roy's Avatar
    Join Date
    09-27-2012
    Location
    New Delhi,India
    MS-Off Ver
    Excel 2013
    Posts
    1,469

    Re: Delete blank cell to the right

    Hi Markos..

    Try this..

    Please Login or Register  to view this content.
    change color are to set your range

  8. #8
    Registered User
    Join Date
    06-28-2010
    Location
    Posen, Poland
    MS-Off Ver
    Excel 2000
    Posts
    46

    Re: Delete blank cell to the right

    thanks Debraj Roy,
    but... your code do the same as below code:
    Please Login or Register  to view this content.
    both codes only reverse horizontally the range, changing cells order...

    codes related to yours: http://stackoverflow.com/questions/9...with-excel-vba
    Last edited by markos97; 07-10-2013 at 01:53 PM.

  9. #9
    Registered User
    Join Date
    06-28-2010
    Location
    Posen, Poland
    MS-Off Ver
    Excel 2000
    Posts
    46

    Re: Delete blank cell to the right

    any other help?

  10. #10
    Forum Expert Debraj Roy's Avatar
    Join Date
    09-27-2012
    Location
    New Delhi,India
    MS-Off Ver
    Excel 2013
    Posts
    1,469

    Re: Delete blank cell to the right

    Sample sheet with expected output.. we cant run macro on JPG..

  11. #11
    Registered User
    Join Date
    06-28-2010
    Location
    Posen, Poland
    MS-Off Ver
    Excel 2000
    Posts
    46

    Re: Delete blank cell to the right

    OK, Debraj Roy, see the attach, in ThisWorkbook, "my" codes, like this:
    Please Login or Register  to view this content.
    In sheet 1 (Arkusz1) - my input data,
    In sheet 2 (Arkusz2) - how looks my output data (but remember we operate on a single sheet - in this case, to show the essence of things - is presented on two sheets)

    ok. see my attach...
    Attached Files Attached Files

  12. #12
    Forum Expert Debraj Roy's Avatar
    Join Date
    09-27-2012
    Location
    New Delhi,India
    MS-Off Ver
    Excel 2013
    Posts
    1,469

    Re: Delete blank cell to the right

    HI Markos...

    Please Login or Register  to view this content.
    With a single error.. If no special cells found, still its inserting a single..

    @ Other:
    Can someone help me , how to catch, if no Specialcells BLANKS found

  13. #13
    Registered User
    Join Date
    06-28-2010
    Location
    Posen, Poland
    MS-Off Ver
    Excel 2000
    Posts
    46

    Re: Delete blank cell to the right

    thank you Debraj,
    yes your macro
    generate this single error, I see it...
    I noticed that the error occurs in the three longest data rows (rows number 16, 18, and 34 - in this case)

    in line
    Please Login or Register  to view this content.
    I change to:
    Please Login or Register  to view this content.
    - it is more convenient for me...

    ps. sorry, my range is M3:AB39 (not AB:40 - but it's not important...);

    hm...? so, What do we do with this error? Any ideas?

  14. #14
    Registered User
    Join Date
    06-28-2010
    Location
    Posen, Poland
    MS-Off Ver
    Excel 2000
    Posts
    46

    Re: Delete blank cell to the right

    sorry , can't use "With selection" ,- because the code work incorrectly...

    your code work great(!) but:
    we must extended our range
    by one empty column (to the right direction)!
    (from the range M3:AB39 to the range M3:AC39,)

    I did it!,- but someone know what's wrong with this code?!

    see the next attach with a correct solution...

    ps. in sheet2 (Arkusz2) incorrectly solution (!), let me explain:
    if we use in our sheet the code first time,
    in the upper right corner,
    in first row, the last cell is blank
    (in this case AC3 is blank!)
    ,but when we clear the date, and run second time our code,
    the results will be perfect every time!
    even after the file is closed and re-open it!

    in sheet1 (Arkusz1) the data before running our code...
    Attached Files Attached Files
    Last edited by markos97; 07-13-2013 at 02:12 AM.

+ 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