Macro for deleting row with condition

Closed
deepak - 9 Feb 2009 à 23:40
 Maoharan Meghala - 29 Jan 2012 à 13:38
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
Related:

6 responses

husssaid Posts 2 Registration date Tuesday 10 March 2009 Status Member Last seen 11 March 2009
11 Mar 2009 à 05:57
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
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
arunv.cse@gmail.com Posts 2 Registration date Thursday 29 October 2009 Status Member Last seen 11 November 2009
11 Nov 2009 à 04:54
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...
.....
provock Posts 31 Registration date Monday 29 December 2008 Status Member Last seen 18 June 2009 3
10 Feb 2009 à 01:57
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
Maoharan Meghala
29 Jan 2012 à 13:38
Thank you very much for that link, but that link doesn't helped me....
hero85 Posts 7 Registration date Thursday 12 March 2009 Status Member Last seen 14 May 2009 8
16 Mar 2009 à 11:09
do you do small macro work for small money?
critenlee Posts 2 Registration date Friday 21 August 2009 Status Member Last seen 21 August 2009
21 Aug 2009 à 19:43
Thanks so much for sharing the post.




Links removed as reported spam