Results 1 to 3 of 3

Thread: Delete rows in Excel [VB]

  1. #1
    Join Date
    Jan 2009
    Posts
    150

    Delete rows in Excel [VB]

    I got a list of data in the excel sheet and would like to create a macro that whenever i sees shows an empty cell in a matrix, I delete all the rows of a table containing one or more empty cells in column A to column P. I am beginner and I can not.

    Thank you in advance for your help?

  2. #2
    Join Date
    Oct 2008
    Posts
    167

    Re: Delete rows in Excel [VB]

    Hi,

    something like this should work:

    1. Sub test ()
    2. Const LIGNE_DEBUT As Long = 1
    3. Const LIGNE_FIN As Long = 6
    4. Const COLONNE_DEBUT As Long = 1
    5. Const COLONNE_FIN As Long = 3
    6. Sunday supprime_ligne As Boolean
    7. Sunday Line As Long
    8. Sunday column As Long
    9. Sunday nb_suppr As Long
    10. nb_suppr = 0
    11. we loop on lines
    12. For row = LIGNE_DEBUT To LIGNE_FIN
    13. 'default this line is not deleted
    14. supprime_ligne = False
    15. we loop over the columns
    16. For column = COLONNE_DEBUT To COLONNE_FIN
    17. Next line
    18. End Sub

    Try to make constants from the beginning and that's all.
    In your case, if you want to go up the column P COLONNE_FIN must apply 16.

    It is probably not very clean but it works.

  3. #3
    Join Date
    Apr 2008
    Posts
    193

    Re: Delete rows in Excel [VB]

    Hi

    Here I will suggest some regarding your coding

    I would add just beginning to code a
    Application.ScreenUpdating = False
    then at the end of the code a
    Application.ScreenUpdating = True

    You hide what excel, and therefore can save time at the execution.

    In addition, the line 27 does nothing, or spend time at the execution.
    Same for lines 36-37, a
    Rows (line & ":" & row). Delete Shift: = xlUp

    If after the last is not a great thing (as the previous If only validate a test on the contents of the cell), but it is not the concern, it works.

    Best regards

Similar Threads

  1. How delete rows between two inputs numbers on Excel?
    By Hridayeshu in forum Windows Software
    Replies: 1
    Last Post: 04-01-2012, 07:56 PM
  2. Replies: 6
    Last Post: 23-07-2011, 01:05 AM
  3. Replies: 2
    Last Post: 09-07-2009, 08:57 AM
  4. How to delete bottom rows in excel
    By Dhanajay in forum Windows Software
    Replies: 2
    Last Post: 25-06-2009, 12:22 PM
  5. Excel macro variable to delete rows
    By JPGargoyle in forum Windows Software
    Replies: 2
    Last Post: 22-06-2009, 11:26 AM

Tags for this Thread

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
  •  
Page generated in 1,711,706,698.87737 seconds with 17 queries