Thread: Selecting Rows
View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
broro183[_35_] broro183[_35_] is offline
external usenet poster
 
Posts: 1
Default Selecting Rows


Hi Anar,

The following macro doesn't use a loop as you have shown below & I
think it may be quicker to execute.
I have used a datafilter to show the "17"'s, select visible rows within
the datarange (+1 row because I offset to prevent the headers being
deleted), & delete them, then removes the autofilter:


Code:
--------------------
Sub DeleteSeventeens ()
Dim FilterRange As String 'line 1, place at start of code
FilterRange = "A1:C10500" 'line 2
Range(FilterRange).AutoFilter Field:=3, Criteria1:="=17", Operator:=xlAnd 'line 3
Range(FilterRange).Offset(1, 0).EntireRow.SpecialCells(xlCellTypeVisible).Delet e Shift:=xlUp 'line 4
Selection.AutoFilter 'line 5
end sub
--------------------


In case my post messes up where the line breaks should be, I have put
them in as comments on the end of each line. NB, the FilterRange can be
changed as required (& currently this macro must be on the same sheet)
- I have declared it as a string but someone may suggest a way of
declaring this as a range.

hth,
Rob Brockett
NZ
Always learning & the best way to learn is to experience...


--
broro183
------------------------------------------------------------------------
broro183's Profile: http://www.excelforum.com/member.php...o&userid=30068
View this thread: http://www.excelforum.com/showthread...hreadid=509939