delete rows within a specific range macro
Hi, I wanted to set up a macro which can delete rows within a certain range.
For example I want to delete all rows that have values in column B between 350 and 650. I also want to delete rows that have values below 250 and above 850 (I have the codes for these, but it would be great to incorporate all 3 into 1 macro) Thanks! |
delete rows within a specific range macro
Please try this and feedback
Sub Macro() Dim lngLastRow, lngRow, varValue lngLastRow = ActiveSheet.Cells(Rows.Count, "B").End(xlUp).Row For lngRow = lngLastRow To 1 Step -1 varValue = Range("B" & lngRow).Value If varValue < 250 Or varValue 850 Or (varValue 350 And varValue < 650) Then ActiveSheet.Rows(lngRow).Delete End If Next End Sub If this post helps click Yes --------------- Jacob Skaria "GraduatePlease09" wrote: Hi, I wanted to set up a macro which can delete rows within a certain range. For example I want to delete all rows that have values in column B between 350 and 650. I also want to delete rows that have values below 250 and above 850 (I have the codes for these, but it would be great to incorporate all 3 into 1 macro) Thanks! |
All times are GMT +1. The time now is 11:27 AM. |
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com