+ Reply to Thread
Results 1 to 15 of 15

delete rows

  1. #1
    Forum Contributor
    Join Date
    10-31-2018
    Location
    venezia
    MS-Off Ver
    2007
    Posts
    492

    delete rows

    Hello everyone,
    I ask for help to delete rows:

    An alert "how many rows you want to delete?"
    example 50
    starting from row 5 it eliminates 50 rows

    must re-enter the formulas for the automatic number in column A
    I hope I explained myself
    john
    Attached Files Attached Files

  2. #2
    Forum Expert PaulM100's Avatar
    Join Date
    10-09-2017
    Location
    UK
    MS-Off Ver
    Office 365
    Posts
    2,108

    Re: delete rows

    This one should do
    Please Login or Register  to view this content.
    Click the * to say thanks.

  3. #3
    Forum Contributor
    Join Date
    10-31-2018
    Location
    venezia
    MS-Off Ver
    2007
    Posts
    492

    Re: delete rows

    Hi poul, thanks you
    An error if I click cancel or click x goes to debug.

  4. #4
    Forum Expert PaulM100's Avatar
    Join Date
    10-09-2017
    Location
    UK
    MS-Off Ver
    Office 365
    Posts
    2,108

    Re: delete rows

    This one should handle that:
    Please Login or Register  to view this content.

  5. #5
    Forum Contributor
    Join Date
    10-31-2018
    Location
    venezia
    MS-Off Ver
    2007
    Posts
    492

    Re: delete rows

    Hi poul
    I did tests.
    In the attached example I deleted 200 lines and then in cell A6 / A6 the text of cell A is shown
    Attached Files Attached Files

  6. #6
    Forum Expert PaulM100's Avatar
    Join Date
    10-09-2017
    Location
    UK
    MS-Off Ver
    Office 365
    Posts
    2,108

    Re: delete rows

    You've deleted more rows than the ones containing data and last row stops in B5 now, that's why. Try this, untested:
    Please Login or Register  to view this content.

  7. #7
    Forum Contributor
    Join Date
    10-31-2018
    Location
    venezia
    MS-Off Ver
    2007
    Posts
    492

    Re: delete rows

    Now it does not delete any line always appears

    MsgBox ("You have entered an invalid row number")

  8. #8
    Forum Expert PaulM100's Avatar
    Join Date
    10-09-2017
    Location
    UK
    MS-Off Ver
    Office 365
    Posts
    2,108

    Re: delete rows

    In a cell type =counta(b6:b200000). This should give you the not empty number of cells. In the macro replace b6:b with b6:b200000. Test it by entering a number smaller that the one returned by the formula first and afterwards one bigger.

  9. #9
    Forum Contributor
    Join Date
    10-31-2018
    Location
    venezia
    MS-Off Ver
    2007
    Posts
    492

    Re: delete rows

    i tried:

    Please Login or Register  to view this content.
    now in the attach does not delete
    Attached Files Attached Files

  10. #10
    Forum Expert PaulM100's Avatar
    Join Date
    10-09-2017
    Location
    UK
    MS-Off Ver
    Office 365
    Posts
    2,108

    Re: delete rows

    This one will handle the data. Please be aware that will not delete rows if the user imputs a number higher than the rows with data based on B column data. If you want to delete them and to not add data in column A, as B is empty, then remove this part from the code: Or (num > Application.CountA(Range("B6:B200000")))
    Please Login or Register  to view this content.

  11. #11
    Forum Contributor
    Join Date
    10-31-2018
    Location
    venezia
    MS-Off Ver
    2007
    Posts
    492

    Re: delete rows

    Hi poul,
    I entered 125 rows
    I tried with delete 123 rows
    the macro deletes 123 rows but does not contain the formula in A7

  12. #12
    Forum Expert PaulM100's Avatar
    Join Date
    10-09-2017
    Location
    UK
    MS-Off Ver
    Office 365
    Posts
    2,108

    Re: delete rows

    I've replicated your issue and not there should be no more issues.

    Please Login or Register  to view this content.
    Last edited by PaulM100; 08-13-2019 at 11:45 AM.

  13. #13
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,722

    Re: delete rows

    Please Login or Register  to view this content.

  14. #14
    Forum Contributor
    Join Date
    10-31-2018
    Location
    venezia
    MS-Off Ver
    2007
    Posts
    492

    Re: delete rows

    Poul, I think is now correct.
    to be sure I have to try it after the summer holidays.
    Greetings and thanks
    john

  15. #15
    Forum Contributor
    Join Date
    10-31-2018
    Location
    venezia
    MS-Off Ver
    2007
    Posts
    492

    Re: delete rows

    Hi poul,
    I tried to change the inputboxes with userform but here I don't know how to insert num in the inputbox.

    Please Login or Register  to view this content.

    I attach example.
    john
    Attached Files Attached Files
    Last edited by john_cash; 08-14-2019 at 03:04 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. Rows delete formula as per range of cell values with counter to delete # rows
    By qureshi2016 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 12-03-2017, 09:35 AM
  2. Delete All Rows Below Criteria in Col A / Then Delete Specific Rows in Col E
    By LennyC91 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-15-2016, 08:22 AM
  3. [SOLVED] how to delete delete rows with criteria and keeping formula
    By Bremmah in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-18-2013, 07:09 AM
  4. [SOLVED] Delete blank rows between data rows, shift rows up, then repeat
    By excelactuary in forum Excel General
    Replies: 2
    Last Post: 03-11-2013, 11:53 AM
  5. Replies: 5
    Last Post: 11-12-2012, 08:38 PM
  6. Macro to delete certain columns and delete rows based on time in another column
    By beepbeep27 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-12-2012, 11:47 AM
  7. delete duplicate rows, delete empty rows
    By loade in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 05-03-2012, 05:42 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