Macro for deleting row with condition

Closed
deepak - Feb 9, 2009 at 11:40 PM
 Maoharan Meghala - Jan 29, 2012 at 01:38 PM
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

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

Mar 11, 2009 at 05:57 AM
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
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
38
This code was great, worked perfectly
0
arunv.cse@gmail.com
Posts
2
Registration date
Thursday October 29, 2009
Status
Member
Last seen
November 11, 2009

Nov 11, 2009 at 04:54 AM
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...
.....
13
provock
Posts
31
Registration date
Monday December 29, 2008
Status
Member
Last seen
June 18, 2009
3
Feb 10, 2009 at 01:57 AM
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
9
Maoharan Meghala
Jan 29, 2012 at 01:38 PM
Thank you very much for that link, but that link doesn't helped me....
0

Didn't find the answer you are looking for?

Ask a question
hero85
Posts
7
Registration date
Thursday March 12, 2009
Status
Member
Last seen
May 14, 2009
8
Mar 16, 2009 at 11:09 AM
do you do small macro work for small money?
5
critenlee
Posts
2
Registration date
Friday August 21, 2009
Status
Member
Last seen
August 21, 2009

Aug 21, 2009 at 07:43 PM
Thanks so much for sharing the post.




Links removed as reported spam
3