LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Find and Delete data in a column

Dear All,

Using MS Excel 2002 I am trying to compare data in column A in sheet A
with column A in Sheet B. For every match I want to delete the entire
row in Sheet B. The code I wrote is as below

i = 2
'Start of loop

Sheets("A").Select
store = Range("B" & i)
Sheets("B").Select
'Columns("A:A").Select --may not be needed

Selection.Find(What:=store, After:=ActiveCell, LookIn:=xlValues, _
LookAt:=xlPart, SearchOrder:=xlByColumns,
SearchDirection:=xlNext, _
MatchCase:=False).Activate

On Error GoTo ErrTrap
ActiveCell.EntireRow.Delete
'..some more code
GoTo Finally
Loop

For a case when a cell in SheetA.ColumnA does not have a match in
SheetB.ColumnA and error is generated which gets handled by the
ErrTrap. This works fine for the first time a match is not found. The
second time a match is not found excel gives a run time error -
Run-time error '91':
Object variable or With blck variable not set

Can anyone tell what is wrong with the code. Thank you in advance.

Regards,
Rahul
 
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
Find last cell in a column, Delete its contents and make it active George Excel Worksheet Functions 5 January 28th 10 05:38 PM
Find last cell in a column, Delete its contents and make it ac Don Guillett[_2_] Excel Worksheet Functions 1 January 28th 10 04:56 PM
FInd common data in one column then add number in adjacent column JT Excel Worksheet Functions 3 December 18th 09 10:20 PM
how to find the data after we delete bayu Excel Discussion (Misc queries) 1 October 11th 08 05:54 PM
macro to find something in column A and delete 5 rows below it vikram Excel Programming 1 April 30th 04 12:04 PM


All times are GMT +1. The time now is 06:22 AM.

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

About Us

"It's about Microsoft Excel"