+ Reply to Thread
Results 1 to 22 of 22

Conditional Delete Cells and shift to the left

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

    Conditional Delete Cells and shift to the left

    Hi,

    I have an input data like that:
    --A-B-C-D-E-F-G
    1-5-7-7-7-5-7-5
    2-7-5-5-5-7-5-7
    3-5-5-5-7-7-5-5
    and so on...

    an output data I need:
    --A-B-C-D-E-F-G
    1-7-7-7-5-7-5
    2-7-5-5-5-7-5-7
    3-7-7-5-5
    and so on...

    as above, macro must to delete number 5 from left to right until not contain other number, and shift to left

    my problem is similar to below:
    Please Login or Register  to view this content.
    above macro works good, but only for one row...

    any help?

    ps. I have also other variant my data, like this:

    input data:
    --A-B-C-D-E-F-G
    1-5-6-3-8-4-1-5
    2-9-5-5-5-6-5-44
    3-5-5-5-6-4-5-5
    and so on...

    output data:
    --A-B-C-D-E-F-G
    1-6-3-8-4-1-5
    2-9-5-5-5-6-5-44
    3-6-4-5-5
    and so on...
    Last edited by markos97; 06-28-2013 at 04:19 AM.

  2. #2
    Valued Forum Contributor
    Join Date
    03-29-2013
    Location
    United Kingdom
    MS-Off Ver
    Office/Excel 2013
    Posts
    1,749

    Re: Conditional Delete Cells and shift to the left

    I'm not clear... Do you want to delete all 5's?
    Elegant Simplicity............. Not Always

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

    Re: Conditional Delete Cells and shift to the left

    no! see my date before and after,
    in this case, I want to delete the number 5 starting from left, and if you meet another number, stop removing

  4. #4
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,197

    Re: Conditional Delete Cells and shift to the left

    Hi, markos97,

    maybe like this:
    Please Login or Register  to view this content.
    Ciao,
    Holger
    Use Code-Tags for showing your code: [code] Your Code here [/code]
    Please mark your question Solved if there has been offered a solution that works fine for you

  5. #5
    Valued Forum Contributor
    Join Date
    09-04-2012
    Location
    india
    MS-Off Ver
    Excel 2007
    Posts
    463

    Re: Conditional Delete Cells and shift to the left

    check the attached file

    i have made some sample data for your solution

    press CTRL+r TWO TIME PRESS.

    If it is really helpful to you then dont forget to hit * button for user reputation

    Regards
    CA Mahaveer Somani
    Attached Files Attached Files

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

    Re: Conditional Delete Cells and shift to the left

    Yeah - That's it!
    Macro works perfectly for me!
    Thanks a lot HAHOBE, AndyLitch also many thanks!
    and you - mahaveersomani (yes I remember) - ps, your code not exactly do what I need (save blank space between cells)
    Last edited by markos97; 06-28-2013 at 04:53 AM.

  7. #7
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,197

    Re: Conditional Delete Cells and shift to the left

    Hi, mahaveersomani,

    your code will delete every occurrance in the sheet, not only those at the beginning of each row until any other number is found.

    Please Login or Register  to view this content.
    Ciao,
    Holger
    Last edited by HaHoBe; 06-28-2013 at 04:55 AM. Reason: code added

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

    Re: Conditional Delete Cells and shift to the left

    yes, you'r right HAHOBE - now I see it error

  9. #9
    Valued Forum Contributor
    Join Date
    09-04-2012
    Location
    india
    MS-Off Ver
    Excel 2007
    Posts
    463

    Re: Conditional Delete Cells and shift to the left

    sorry @hahobe........now i see the his question properly........now i m thinking that still i could not understand which kind of this problem.....i mean what is his needs.....confused......by the way its ok...hahobe.......good day dear..


    Regards
    CA Mahaveer Somani

  10. #10
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,197

    Re: Conditional Delete Cells and shift to the left

    Hi, mahaveersomani,

    using your approach the code may look like
    Please Login or Register  to view this content.
    Ciao,
    Holger

  11. #11
    Valued Forum Contributor
    Join Date
    09-04-2012
    Location
    india
    MS-Off Ver
    Excel 2007
    Posts
    463

    Re: Conditional Delete Cells and shift to the left

    thanks to guide me..........@hahobe

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

    Re: Conditional Delete Cells and shift to the left

    one again, thank you HaHoBe, now your code looks like:

    Please Login or Register  to view this content.
    I need change this part of code
    Please Login or Register  to view this content.
    to something like that:
    Please Login or Register  to view this content.
    but it does not work like I wanted;
    I need only clear this cells (not shift to left in this moment), I'm try it, but the cells go to up...

    --edit--

    as above my input data looks like

    --A-B-C-D-E-F-G
    1- -7-7-7-5-7-5
    2-7-5-5-5-7-5-7
    3- - - -7-7-5-5
    Last edited by markos97; 07-17-2013 at 04:06 PM.

  13. #13
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,197

    Re: Conditional Delete Cells and shift to the left

    Hi, markos97,

    sory but a sample workbook with what it looks like now and what it should look like after the macro would make things clearer. What should be cleared in Column A/B/what cells? The new sample isnīt explaining itself, and there is not 5 or 55 in the fist column as far as I can judge.

    Ciao,
    Holger

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

    Re: Conditional Delete Cells and shift to the left

    yes, you're right - HaHoBe

    see the attach - alles clear :-)
    Attached Files Attached Files

  15. #15
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,197

    Re: Conditional Delete Cells and shift to the left

    Hi, markos97,

    to my opinion this is a different problem to what you originally asked help for.

    Code for a standard module:
    Please Login or Register  to view this content.
    Ciao,
    Holger

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

    Re: Conditional Delete Cells and shift to the left

    thanks HaHoBe, but something is wrong, macro clear all "99" from A4 to AD2348 and don't touch A2349:AD2377

    see the sample with an error after running your code, here
    Attached Files Attached Files

  17. #17
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,197

    Re: Conditional Delete Cells and shift to the left

    Hi, markos97,

    with an error
    If that should mean the cells havenīt been changed Iīve got it. If not please explain the error that you mean.

    Please Login or Register  to view this content.
    or
    Please Login or Register  to view this content.
    Ciao,
    Holger

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

    Re: Conditional Delete Cells and shift to the left

    problem lies in the fact that your codes clean all the cells 99!!! still is wrong!

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

    Re: Conditional Delete Cells and shift to the left

    maybe you can't open my attach "condtdelcells2.xlsm"?
    maybe see, the screen (this sceen presents data after running the code)

    ps, my USED (non-blank cells) range is A4:AD2377 (in this case) - but this is not a whole range to clear!
    Attached Images Attached Images
    Last edited by markos97; 07-18-2013 at 02:45 AM.

  20. #20
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,197

    Re: Conditional Delete Cells and shift to the left

    Hi, markos97,

    Iīm afraid I got the problem wrong this morning - resulting in a wrong code. Letīs start it over again and maybe you can give this code a try:
    Please Login or Register  to view this content.
    Ciao,
    Holger

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

    Re: Conditional Delete Cells and shift to the left

    yes, that's it!
    once again thank you very much HaHoBe!

    ps.
    to my opinion this is a different problem to what you originally asked help for
    - maybe a slight modification :D

  22. #22
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,197

    Re: Conditional Delete Cells and shift to the left

    Hi, markos97,

    glad we finally got it sorted out the way you expected it to work. Could you please mark this thread as Solved via Thread Tools? Thanks.

    Ciao,
    Holger

+ 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