LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,069
Default find/delete data on different tabs

see if this does what you want. Suggest that you make back-up of your data
before testing.

Sub DeleteData()

Dim ws1 As Worksheet
Dim ws2 As Worksheet
Dim StartRow As Long
Dim EndRow As Long
Dim Lr As Long
Dim FoundCell As Range
Dim Search As String
Dim icount As Long

With ThisWorkbook

Set ws1 = .Worksheets("untitled")
Set ws2 = .Worksheets("bluecard_homeplanaid")

End With

'assume you have a header in row 1
StartRow = 2

icount = 0

With ws1

EndRow = .Cells(.Rows.Count, "B").End(xlUp).Row

For Lr = StartRow To EndRow

Search = .Cells(Lr, 2).Value

If Search < "" Then

Set FoundCell = ws2.Columns(2).Find(Search, _
After:=ws2.Cells(1, 2), _
LookIn:=xlValues, _
LookAt:=xlWhole, _
SearchOrder:=xlByRows, _
SearchDirection:=xlNext, _
MatchCase:=False, _
SearchFormat:=False)

If FoundCell Is Nothing = False Then

FoundCell.EntireRow.Delete

icount = icount + 1

End If

End If

Next

End With

msg = MsgBox(icount & " Records Deleted", vbInformation, "Delete Data")

End Sub

--
jb


"Peruanos72" wrote:

Hello all,

I have a tab named "untitled" and a tab named "bluecard_homeplanaid".
I have data in tab "untitled" column "B". They're numbers such as
200906180333.
I need code to that takes the number in the first cell "B1" in tab
"untitled" and searches column "B" in tab "bluecard_homeplanaid". If found,
then that row in tab "bluecard_homeplanaid" would be deleted. This process
repeats for all of the numbers in column "B" in tab "untitled.

Note: The amount of data in column "B" , tab "untitled" changes daily.

thanks in advance!!!

 
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 find the data after we delete bayu Excel Discussion (Misc queries) 1 October 11th 08 05:54 PM
Delete if find a data format Junior728 Excel Programming 2 May 11th 07 09:50 AM
How can I find and delete tabs and carriage returns ? JeffEE Excel Discussion (Misc queries) 1 November 11th 05 02:47 PM
Find last row of data and delete empty rows Pat Excel Programming 3 February 17th 05 12:34 AM
Find and Delete data in a column rahul_chatterjee[_2_] Excel Programming 4 October 25th 04 11:08 PM


All times are GMT +1. The time now is 05:00 PM.

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"