Use the special cells offering for this but if you wanted to find something 
else you could use data>filter>autofilter.
or to loop to delete start from the bottom up
sub delblanks()
for I =cells(rows.count,end(xlup).row to 2 step –1
if len(application.trim(cells(I, “a”)))<1 then rows(i).delete
next i

end sub

or more criteria (again filtering better)
sub delblanksA()
for I =cells(rows.count,end(xlup).row to 2 step –1
if len(application.trim(cells(I, “a”)))<1 and cells(I,”b”)=”something” then 
rows(i).delete
next i

end sub
or 



Don Guillett
Microsoft Excel Developer
SalesAid Software
dguille...@gmail.com

From: Tony O 
Sent: Wednesday, July 25, 2012 6:43 PM
To: excel-macros@googlegroups.com 
Subject: $$Excel-Macros$$ Excel VBA to loop through rows and delete blank lines

I am working on a spreadsheet with Excel 2007.
I have the vba code to delete a line:

Selection.Delete Shift:=xlUp

I want to delete all rows that have the cells in column A that are blank and  
column B and column C for just those rows.

I'm thinking that the code should look something like this, but I am not 
getting it to work the way I want to:

dim rowchk as integer

for rowchk = 1 to 1000
if activecell.Arowchk ="" then Selection.Delete Shift:=xlUp
end if

Please advise.





-- 
-- 
FORUM RULES (986+ members already BANNED for violation)
 
1) Use concise, accurate thread titles. Poor thread titles, like Please Help, 
Urgent, Need Help, Formula Problem, Code Problem, and Need Advice will not get 
quick attention or may not be answered.
 
2) Don't post a question in the thread of another member.
 
3) Don't post questions regarding breaking or bypassing any security measure.
 
4) Acknowledge the responses you receive, good or bad.
 
5) Cross-promotion of, or links to, forums competitive to this forum in 
signatures are prohibited. 
 
NOTE : Don't ever post personal or confidential data in a workbook. Forum 
owners and members are not responsible for any loss.
 
------------------------------------------------------------------------------------------------------
To post to this group, send email to excel-macros@googlegroups.com
 
To unsubscribe, send a blank email to excel-macros+unsubscr...@googlegroups.com
 
 

-- 
-- 
FORUM RULES (986+ members already BANNED for violation)

1) Use concise, accurate thread titles. Poor thread titles, like Please Help, 
Urgent, Need Help, Formula Problem, Code Problem, and Need Advice will not get 
quick attention or may not be answered.

2) Don't post a question in the thread of another member.

3) Don't post questions regarding breaking or bypassing any security measure.

4) Acknowledge the responses you receive, good or bad.

5)  Cross-promotion of, or links to, forums competitive to this forum in 
signatures are prohibited. 

NOTE  : Don't ever post personal or confidential data in a workbook. Forum 
owners and members are not responsible for any loss.

------------------------------------------------------------------------------------------------------
To post to this group, send email to excel-macros@googlegroups.com

To unsubscribe, send a blank email to excel-macros+unsubscr...@googlegroups.com


Reply via email to