Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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! |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
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! |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
How to Delete rows with blank or specific value in a Macro ? | Excel Programming | |||
Macro to delete specific rows in different worksheets | Excel Programming | |||
Macro to delete rows containing specific data | New Users to Excel | |||
Macro to delete specific rows | Excel Programming | |||
Macro to delete specific rows | Excel Programming |