Thread: Range selection
View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
m1ke m1ke is offline
external usenet poster
 
Posts: 1
Default Range selection


Hi all,

I found a macro on the net that does pretty much what I want, apar
from the fact that it only searches 1 column - not a range of column
as I would like.

Here is the code...


Code
-------------------
Sub Delete_Rows()
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
Dim rng As Range, cell As Range, del As Range
Set rng = Intersect(Range("J:J"), ActiveSheet.UsedRange)
For Each cell In rng
If (cell.Value) = "1" Then
If del Is Nothing Then
Set del = cell
Else: Set del = Union(del, cell)
End If
End If
Next cell
On Error Resume Next
del.EntireRow.Delete
Application.Calculation = xlCalculationAutomatic
Application.ScreenUpdating = True
End Su
-------------------


Basically, I require the macro to search through every cell in column
J to R, and when it finds a "1", delete the entire row. As you can see
the above works for just column J, but I'm not sure of the correc
syntax when trying to select a range of columns.

Any help appreciated

--
m1k
-----------------------------------------------------------------------
m1ke's Profile: http://www.excelforum.com/member.php...fo&userid=3051
View this thread: http://www.excelforum.com/showthread.php?threadid=50169