Computing.Net > Forums > Programming > deleting rows from Excel with Macro

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

deleting rows from Excel with Macro

Reply to Message Icon

Name: sunilmulay
Date: October 5, 2008 at 19:42:06 Pacific
OS: Windows Vista
CPU/Ram: dv6000
Product: HP Pavillion dv6000
Comment:

I'm a VBA newbie. I want to set a macro to delete rows. There are two conditions. If the user selects a row where there is data in column D in the row containing the active cell, then the macro should delete the row as well as the 5 following rows. If the user selects a row where there is no data in column D, then only that row should be deleted.

any ideas?

thanks! Sunil



Sponsored Link
Ads by Google

Response Number 1
Name: Razor2.3
Date: October 6, 2008 at 04:33:13 Pacific
Reply:

Sub something()
If Intersect(ActiveCell.EntireRow, ActiveSheet.Columns("$D")).Value <> "" Then
For i = 1 To 5
ActiveCell.EntireRow.Delete
Next 'i
Else
ActiveCell.EntireRow.Delete
End If
End Sub


0

Response Number 2
Name: sunilmulay
Date: October 6, 2008 at 05:02:47 Pacific
Reply:

thank you!


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: deleting rows from Excel with Macro

Delete Row from GridView www.computing.net/answers/programming/delete-row-from-gridview/15172.html

Delete rows with vba macro www.computing.net/answers/programming/delete-rows-with-vba-macro/8233.html

excel vba macro assistance www.computing.net/answers/programming/excel-vba-macro-assistance/10837.html