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: 27,285
Default avoiding duplicates

Dim sVal as Variant, rng as Range, rng2 as Range
Dim cnt as long

With worksheets ("Deals")
Set rng = .cells(Rows.Count,1).End(x1up) (2)
Set rng2 =.Range(Cells(1,1), rng(0))
End With

sVal = Worksheets("Sheet1").Range("Customer").Value
cnt = Application.Countif(rng2,sVal)
if cnt = 0 then
rng.Offset(0,0).Value = Worksheets("Sheet1").Range("Customer")
rng.Offset(0,1).Value = Worksheets("Sheet1").Range("Date")
End if

Assumes the Range("Customer") is a single cell.

Probably not exactly what you need, but you left out more than you told.

--
Regards,
Tom Ogilvy

"Jeremy" wrote in message
...
Hi, I have already asked this but I am still struglling with it.

I have a spreadsheet which has the cells in a row poplulated from cells in

a source sheet using this code:

With worksheets ("Deals")
Set rng = .cells(Rows.Count,1).End(x1up) (2)
End With

rng.Offset(0,0).Value = Worksheets("Sheet1").Range("Customer")
rng.Offset(0,1).Value = Worksheets("Sheet1").Range("Date")

etc for the rest of the cells in the row.

I need code to ensure that the content from the source sheet is not

already in a row in the target sheet. i.e avoid duplicates. if so an error
message is displayed and the operation cancelled.



 
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
Avoiding #N/A gibbylinks Excel Discussion (Misc queries) 8 February 6th 10 12:51 PM
Avoiding Duplicates Craig Excel Discussion (Misc queries) 6 December 10th 09 09:08 PM
AVOIDING DUPLICATES IN A RANGE OF CELLS Glint Excel Discussion (Misc queries) 11 August 9th 06 11:54 AM
Avoiding Duplicates Mald Excel Discussion (Misc queries) 4 August 1st 06 03:38 PM
Avoiding duplicates jeremy Excel Programming 1 April 19th 04 06:06 PM


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