Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default delete content of one sheet off another sheet

I have got 2 excel sheet. Both contain a table(lets call it table1 and
table2). Both the tables have the same kind of formatting.

table1 contains other entries + table2

I want to remove table2 entries off table1.

What is the best way of going about it?


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 923
Default delete content of one sheet off another sheet

One way is to scan table 1 and check each row (and column) in table 2 for a
match. If any column fails to match move to next table 2 entry. If all
columns match rrow from table 1.
If your tables are very big then this process can take a while to run.


Sub Test()

Dim t1LR As Long, t2LR As Long, t1CR As Long, t2CR As Long
Dim tCol As Integer, tCC As Integer, xMatch As Boolean

Application.ScreenUpdating = False

' get extent of table 1 and 2 and number of columns
' assumes tables start in column 1
t1LR = Sheets(1).Cells(Rows.Count, 1).End(xlUp).Row
t2LR = Sheets(2).Cells(Rows.Count, 1).End(xlUp).Row
tCol = Sheets(1).Cells(1, Columns.Count).End(xlToLeft).Column

' scan tables
' assumes tables start in row 1
For t1CR = t1LR To 1 Step -1
For t2CR = 1 To t2LR
xMatch = True
For tCC = 1 To tCol
If Sheets(1).Cells(t1CR, tCC) < Sheets(2).Cells(t2CR, tCC) Then
xMatch = False
Exit For
End If
Next tCC
If xMatch = True Then Sheets(1).Rows(t1CR).EntireRow.Delete
shift:=xlShiftUp
Next t2CR
Next t1CR
Application.ScreenUpdating = True

End Sub

--
Cheers
Nigel



"eureka" <eureka @discussions.microsoft.com wrote in message
...
I have got 2 excel sheet. Both contain a table(lets call it table1 and
table2). Both the tables have the same kind of formatting.

table1 contains other entries + table2

I want to remove table2 entries off table1.

What is the best way of going about it?




Reply
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
Delete ROW on Sheet#1 corupts data on Sheet#2 Duane Excel Worksheet Functions 4 February 11th 10 07:53 PM
Delete values in sheet 2 that arre found in sheet 1 np Excel Discussion (Misc queries) 1 December 10th 09 07:21 PM
Delete rows from one sheet containing deatils on the second sheet [email protected] New Users to Excel 4 September 6th 07 11:10 AM
sheet tab = to cell content reaa Excel Discussion (Misc queries) 5 February 26th 07 07:06 PM
copy content of 1 sheet to another one. Maileen[_4_] Excel Programming 1 February 22nd 06 07:39 AM


All times are GMT +1. The time now is 04:32 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"