Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8,520
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to Delete rows with blank or specific value in a Macro ? Glenn Excel Programming 1 November 1st 08 06:23 AM
Macro to delete specific rows in different worksheets [email protected] Excel Programming 5 March 19th 07 10:24 PM
Macro to delete rows containing specific data Slohcin New Users to Excel 2 December 20th 06 11:52 AM
Macro to delete specific rows Gert-Jan[_2_] Excel Programming 2 December 20th 06 09:29 AM
Macro to delete specific rows Steve Excel Programming 12 October 1st 04 11:50 PM


All times are GMT +1. The time now is 08:18 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"