View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Zoltan Zoltan is offline
external usenet poster
 
Posts: 25
Default Selective Copy from other excel file, sort, then delete on a condi

Hello,

If I understand well your question, then I would use a double loop for your
problem

Private Sub CommandButton1_Click()

Dim rng1, rng2 As Range
Dim mycell1, mycell2 As Range
Set rng = Range("A1:A15")

For Each mycell1 In rng
For Each mycell2 In rng
If (mycell2.Text = mycell1.Text) And (mycell1.Row < mycell2.Row) Then
rng.Rows(mycell2.Row).Delete
End If
Next
Next

End Sub


You need to modify the code according to your needs!

Regards,
Zoltan

"Adi M" wrote:

Hi. I have two excel files, Excel-1 and Excel-2. I must copy from Excel-1 to Excel-2 only some columns (for example A,B,D and G). After this copy, in the Excel-2 file, i must search in a column (A) for duplicates. If i found one, a script must delete the entire row. (for example A34 and A45 are the same with A2 - then i should delete A34 and A45)
The A file is updated daily - that's why I need a macro to be run every day to check if new rows appeared, and if yes, to add them by the end of Excel-B.
Can you help me please in this problem?

Thank you very much!

EggHeadCafe - .NET Developer Portal of Choice
http://www.eggheadcafe.com