+ Reply to Thread
Results 1 to 15 of 15

Delete row if cells in columns A to D are <0

  1. #1
    Forum Contributor
    Join Date
    06-05-2013
    Location
    Austria
    MS-Off Ver
    Excel 2016
    Posts
    165

    Delete row if cells in columns A to D are <0

    Hi everyone,
    I need your help, please. I need a macro that deletes all rows in which the value of the cells from columns A to D are <1.
    The values are starting from A10 to D10.

    For Example:

    A B C D
    10 1 2,5 3 0
    11 0 0 0 0
    12 5 0 0 0

    The macro should delete row 11 because there are all values <1.

    Thanks a lot
    Kind regards
    Roman

  2. #2
    Forum Guru
    Join Date
    02-27-2016
    Location
    Vietnam
    MS-Off Ver
    2016
    Posts
    5,913

    Re: Delete row if cells in columns A to D are <0

    Try;
    Please Login or Register  to view this content.

  3. #3
    Forum Contributor
    Join Date
    06-05-2013
    Location
    Austria
    MS-Off Ver
    Excel 2016
    Posts
    165

    Re: Delete row if cells in columns A to D are <0

    Thanks a lot. I will try it.

  4. #4
    Forum Contributor
    Join Date
    06-05-2013
    Location
    Austria
    MS-Off Ver
    Excel 2016
    Posts
    165

    Re: Delete row if cells in columns A to D are <0

    Hy, I have tried to modify the macro:

    Please Login or Register  to view this content.
    The idea is to check first if there are only numbers typed into the inputbox. This works. But I have problems to delete the rows if the number is =< in rows A to D. There happens nothing.
    Can you help me please?
    Thanks a lot.
    Kind regards
    Roman

  5. #5
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Re: Delete row if cells in columns A to D are <0


    Hi !

    Attach a workbook, could be easier to help … Criteria is < 0 or = 0 ?

  6. #6
    Forum Contributor
    Join Date
    06-05-2013
    Location
    Austria
    MS-Off Ver
    Excel 2016
    Posts
    165

    Re: Delete row if cells in columns A to D are <0

    Criteria < the value of the input box or equal to the input box

  7. #7
    Forum Contributor
    Join Date
    06-05-2013
    Location
    Austria
    MS-Off Ver
    Excel 2016
    Posts
    165

    Re: Delete row if cells in columns A to D are <0

    Hi, here is the workbook
    Attached Files Attached Files

  8. #8
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Re: Delete row if cells in columns A to D are <0


    It seems your workbook does not match with your original explanation :

    Quote Originally Posted by moosmahna View Post
    The values are starting from A10 to D10.
    As the better original explanation & attachment, the quicker & better solution !

    So explain clearly what do to with your attachment …

  9. #9
    Forum Contributor
    Join Date
    06-05-2013
    Location
    Austria
    MS-Off Ver
    Excel 2016
    Posts
    165

    Re: Delete row if cells in columns A to D are <0

    Hi Marc,
    If you start the macro, you get the inputbox. There you have to type in a number. The macro looks if it is a number. If not, then the macro can be stopped or you can try to type in a number again.
    If you have typed in a number, then it is stored in the variable "wert".
    With this number, the macro searches on sheet "Import" if the number "wert" is smaller or equal in the cells A-D in each row. If the number in a row, column A-D (in all Columns of this row), is equal or smaller then the varible "wert", then the row has to be deletet.

    Thanks again

  10. #10
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Cool Try this ‼


    As a beginner starter like operating manually :

    PHP Code: 
    Sub Demo1()
         
    Dim V
             V 
    InputBox(vbLf vbLf "Valeur plancher :""  Suppression de lignes")
             If 
    Not IsNumeric(VThen Exit Sub
             Application
    .ScreenUpdating False
        With ImportData
    .UsedRange.Resize(, 5).Rows
            
    .Columns(5).Formula Replace("=AND(A1<=#,B1<=#,C1<=#,D1<=#)""#"V)
            .
    Sort .Cells(5), xlAscendingHeader:=xlNo
             V 
    Application.Match(True, .Columns(5), 0)
             If 
    IsNumeric(VThen .Item(":" & .Count).Clear
            
    .Columns(5).Clear
        End With
             Application
    .ScreenUpdating True
    End Sub 
    Do you like it ? So thanks to click on bottom left star icon « Add Reputation » !

  11. #11
    Forum Contributor
    Join Date
    06-05-2013
    Location
    Austria
    MS-Off Ver
    Excel 2016
    Posts
    165

    Re: Delete row if cells in columns A to D are <0

    Hi Marc,
    thanks for your help. It looks very good. I will try to modify it. Can´t believe that the code can be so small.

  12. #12
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Re: Delete row if cells in columns A to D are <0


    Thanks for the rep' !

    The code can be so small just thinking how Excel can help instead of a poor full VBA way
    as using a loop can be the slowest way, as clearing a block at once - even manually ! - is faster than deleting row by row …

  13. #13
    Forum Contributor
    Join Date
    06-05-2013
    Location
    Austria
    MS-Off Ver
    Excel 2016
    Posts
    165

    Re: Delete row if cells in columns A to D are <0

    Hi Marc,
    I have modified the code but now nothing happens.....

    Please Login or Register  to view this content.
    Any ideas what is wrong with the code?
    Thanks again

  14. #14
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Re: Delete row if cells in columns A to D are <0


    Maybe a bad entry …

    Try my original Demo1 with your original attachment with value = 2.
    Last edited by Marc L; 08-08-2018 at 07:59 AM.

  15. #15
    Valued Forum Contributor
    Join Date
    04-01-2015
    Location
    The Netherlands
    MS-Off Ver
    2003/2007/2010/2016/office 365
    Posts
    880

    Re: Delete row if cells in columns A to D are <0

    As an alternative
    Please Login or Register  to view this content.
    Last edited by Vraag en antwoord; 08-08-2018 at 08:45 AM.

+ 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. Compare 2 columns, delete cells with no match
    By cmd in forum Excel Programming / VBA / Macros
    Replies: 14
    Last Post: 07-22-2019, 04:52 AM
  2. [SOLVED] VBA to Check Through Cells for 2 Columns and Delete Row if Cells Contains
    By Astriddd in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 06-29-2015, 02:27 AM
  3. Delete Columns if cells in row 5 has a specific Text
    By VKu in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 03-19-2015, 08:52 AM
  4. Delete The cells above a red colored cell in columns
    By zeroist in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 02-10-2014, 05:33 AM
  5. Delete empty cells from Columns
    By MKZS in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-06-2013, 07:57 AM
  6. Delete The cells above a specific cell in columns
    By zeroist in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 11-28-2013, 02:56 AM
  7. Need to delete cells, not columns or rows, based on LEN=0
    By jenny_journalist in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 12-29-2009, 04:11 PM

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