Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Tags Active Topics RSS Search Mark Forums Read

Thread Tools Search this Thread
Old 03-02-2009
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?
Reply With Quote
Old 03-02-2009
Join Date: Oct 2008
Posts: 167
Re: Delete rows in Excel [VB]


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
  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.
Reply With Quote
Old 03-02-2009
Join Date: Apr 2008
Posts: 193
Re: Delete rows in Excel [VB]


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
Reply With Quote

  TechArena Community > Software > Software Development
Tags: ,

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Similar Threads for: "Delete rows in Excel [VB]"
Thread Thread Starter Forum Replies Last Post
How delete rows between two inputs numbers on Excel? Hridayeshu Windows Software 1 04-01-2012 07:56 PM
Looking for a Excel Macro to delete rows which doesn?t contain a value in particular cell Antariksh Windows Software 6 23-07-2011 01:05 AM
Merging duplicate names not rows copy rows into new workbook each time VBA Excel 2003 awkwardsmile Software Development 2 09-07-2009 08:57 AM
How to delete bottom rows in excel Dhanajay Windows Software 2 25-06-2009 12:22 PM
Excel macro variable to delete rows JPGargoyle Windows Software 2 22-06-2009 11:26 AM

All times are GMT +5.5. The time now is 07:26 AM.