Macro for deleting row with condition [Closed]

Report
-
 Maoharan Meghala -
Hello,

suppose I have one column in which there are 24 rows i.e. A1:A24 and these rows contain some value

I need to make one macro in which I want to delete rows which have value greater than 5

6 replies

Posts
2
Registration date
Tuesday March 10, 2009
Status
Member
Last seen
March 11, 2009

I have pasted table with some other information not in the table , needs to delete rows that the fourth column does not contain an number
63
Thank you

A few words of thanks would be greatly appreciated. Add comment

CCM 2942 users have said thank you to us this month

Private Sub Delete()


Dim intRow
Dim intLastRow
intLastRow = Range("A65536").End(xlUp).Row


For intRow = intLastRow To 1 Step -1

Rows(intRow).Select
If Cells(intRow, 1).Value > 5 Then
Cells(intRow, 1).Select
Selection.EntireRow.Delete

End If

Next intRow

Range("A1").Select


End Sub

The macro above will not delete blank rows. If you need to delete blank rows also in the range then use this.

Private Sub Delete()


Dim intRow
Dim intLastRow
intLastRow = Range("A65536").End(xlUp).Row


For intRow = intLastRow To 1 Step -1

Rows(intRow).Select
If Cells(intRow, 1).Value > 5 Or Cells(intRow, 1) = "" Then
Cells(intRow, 1).Select
Selection.EntireRow.Delete

End If

Next intRow

Range("A1").Select


End Sub
This code was great, worked perfectly
Posts
2
Registration date
Thursday October 29, 2009
Status
Member
Last seen
November 11, 2009

hi,,,,,i want to delete the empty column but,,having values in header.... that is in a1 cell...how to delete the entire column....also the heading...
.....
Posts
31
Registration date
Monday December 29, 2008
Status
Member
Last seen
June 18, 2009
3
I'm not very fnd of creating macro or VBA stuffs, but if you want a good example of a macro use to delete rows , just copy and paste this link in the address bar of your browser :https://docs.microsoft.com/en-us/office/troubleshoot/excel/delete-every-other-row

Thank you very much for that link, but that link doesn't helped me....
Posts
7
Registration date
Thursday March 12, 2009
Status
Member
Last seen
May 14, 2009
8
do you do small macro work for small money?
Posts
2
Registration date
Friday August 21, 2009
Status
Member
Last seen
August 21, 2009

Thanks so much for sharing the post.




Links removed as reported spam

Subscribe To Our Newsletter!

The Best of CCM in Your Inbox

Subscribe To Our Newsletter!