View Single Post
  #7   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default Delete Cells Based on Range

Sub DeleteMatches()
dim rng as Range, rng1 as Range
Dim res as Variant, cell as Range
With Worksheets("Sheet1")
set rng = .Range(.Cells(2,"E"),.Cells(2,"E").End(xldown))
end With
for each cell in rng
With Worksheets("Sheet2")
set rng1 = .range(".Cells(2,1),.Cells(2,1).End(xldown))
End with
res = Application.Match(clng(cell),rng1,0)
if not iserror(res) then
rng1(res).EntireRow.Delete
end if
Next
End sub

--
Regards,
Tom Ogilvy



"STEVEB" wrote in
message ...

Hi Tom,

Thanks for the input, I appreciate it! I am still not getting the code
to work properly.

For example:

Column A - Sheet 2 lists every date beginning 1/1/2005 through 7/31/05.
210 rows.

Column E - Sheet 1 lists about 20 dates(1/1/2005, 6/8/2005, 5/4/2005,
12/30/2005, etc.). The range is E2:E50 (Only E2:e21 has a date in it
this month, however, so months there are up to 50 dates)

What I would like is to run a Macro that would compare Column E - Sheet
1 to Column A - Sheet 2. If Column A - Sheet 2 has any date listed in
Column E - Sheet 1, I would like to delete the entire row in Column A
Sheet 2.

I hope this helps. Thanks again


--
STEVEB
------------------------------------------------------------------------
STEVEB's Profile:

http://www.excelforum.com/member.php...fo&userid=1872
View this thread: http://www.excelforum.com/showthread...hreadid=390607