Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 360
Default loop to check for duplicates Newbie pls help

I have random program numbers in a cell in each row for example in R4,C4,
406518,417615, 42586. I need to run through all the rows with a loop to
check that there are no duplicate numbers in any of the other cells. I need
an inner and an outer loop. I have the outer loop I think. I need to
compare the first line cell contents and then run through every row to make
sure the first program numbers aren't in any other cells. Then I need to
proceed to the second line compare those numbers with every other line
through the end of the spread sheet ensuring that there are no duplicate
program numbers in the 2nd column.

Here is all I have so far:
Sub ckDups()
Range("R1C2").Select
Do While ActiveCell.Value < ""
???????????
ActiveCell.Offset(1, 0).Select
Loop
End Sub

thanks very much
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default loop to check for duplicates Newbie pls help

Without knowing anything more about your numbers, I would go with this.
Change A1:A100 to reflect the cells you want to check

Sub ABC()
Dim rng as Range, cell as Range
Dim i as Long, c1 as Long
set rng = Range("A1:A100")
for each cell in rng("A1:A100")
v = split(cell.Text,",")
for i = lbound(v) to ubound(v)
c1 = application.countif(rng,"*" & v(i) &"*")
if c1 1 then ' it should be 1 to match itself
msgbox v(i) & " possible dups"
cell.Interior.ColorIndex = 3
end if
next
Next
End Sub

--
regards,
Tom Ogilvy


"Janis" wrote:

I have random program numbers in a cell in each row for example in R4,C4,
406518,417615, 42586. I need to run through all the rows with a loop to
check that there are no duplicate numbers in any of the other cells. I need
an inner and an outer loop. I have the outer loop I think. I need to
compare the first line cell contents and then run through every row to make
sure the first program numbers aren't in any other cells. Then I need to
proceed to the second line compare those numbers with every other line
through the end of the spread sheet ensuring that there are no duplicate
program numbers in the 2nd column.

Here is all I have so far:
Sub ckDups()
Range("R1C2").Select
Do While ActiveCell.Value < ""
???????????
ActiveCell.Offset(1, 0).Select
Loop
End Sub

thanks very much

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 360
Default loop to check for duplicates Newbie pls help

thanks, I WILL TRY IT, just seeing the structures help me get started. I
can probably tweak it to get it to work. Will this one take all the numbers
in the cell and check it against all the numbers in all the other cells
plural?
Regards,
Janis

"Tom Ogilvy" wrote:

Without knowing anything more about your numbers, I would go with this.
Change A1:A100 to reflect the cells you want to check

Sub ABC()
Dim rng as Range, cell as Range
Dim i as Long, c1 as Long
set rng = Range("A1:A100")
for each cell in rng("A1:A100")
v = split(cell.Text,",")
for i = lbound(v) to ubound(v)
c1 = application.countif(rng,"*" & v(i) &"*")
if c1 1 then ' it should be 1 to match itself
msgbox v(i) & " possible dups"
cell.Interior.ColorIndex = 3
end if
next
Next
End Sub

--
regards,
Tom Ogilvy


"Janis" wrote:

I have random program numbers in a cell in each row for example in R4,C4,
406518,417615, 42586. I need to run through all the rows with a loop to
check that there are no duplicate numbers in any of the other cells. I need
an inner and an outer loop. I have the outer loop I think. I need to
compare the first line cell contents and then run through every row to make
sure the first program numbers aren't in any other cells. Then I need to
proceed to the second line compare those numbers with every other line
through the end of the spread sheet ensuring that there are no duplicate
program numbers in the 2nd column.

Here is all I have so far:
Sub ckDups()
Range("R1C2").Select
Do While ActiveCell.Value < ""
???????????
ActiveCell.Offset(1, 0).Select
Loop
End Sub

thanks very much

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 360
Default loop to check for duplicates Newbie pls help

I have another question. There are the &quot's in my question email that I
did not put in.
Is that because I am on a mac? How do I get it to not put in the escape
characters?
Janis
"Tom Ogilvy" wrote:

Without knowing anything more about your numbers, I would go with this.
Change A1:A100 to reflect the cells you want to check

Sub ABC()
Dim rng as Range, cell as Range
Dim i as Long, c1 as Long
set rng = Range("A1:A100")
for each cell in rng("A1:A100")
v = split(cell.Text,",")
for i = lbound(v) to ubound(v)
c1 = application.countif(rng,"*" & v(i) &"*")
if c1 1 then ' it should be 1 to match itself
msgbox v(i) & " possible dups"
cell.Interior.ColorIndex = 3
end if
next
Next
End Sub

--
regards,
Tom Ogilvy


"Janis" wrote:

I have random program numbers in a cell in each row for example in R4,C4,
406518,417615, 42586. I need to run through all the rows with a loop to
check that there are no duplicate numbers in any of the other cells. I need
an inner and an outer loop. I have the outer loop I think. I need to
compare the first line cell contents and then run through every row to make
sure the first program numbers aren't in any other cells. Then I need to
proceed to the second line compare those numbers with every other line
through the end of the spread sheet ensuring that there are no duplicate
program numbers in the 2nd column.

Here is all I have so far:
Sub ckDups()
Range("R1C2").Select
Do While ActiveCell.Value < ""
???????????
ActiveCell.Offset(1, 0).Select
Loop
End Sub

thanks very much

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 360
Default loop to check for duplicates Newbie pls help

Any way I took out all the &quots and it compiles. I think it looks like the
comma in the cell split allows it to check for all the numbers in each cell
so it looks like it will work. Thanks again.

"Tom Ogilvy" wrote:

Without knowing anything more about your numbers, I would go with this.
Change A1:A100 to reflect the cells you want to check

Sub ABC()
Dim rng as Range, cell as Range
Dim i as Long, c1 as Long
set rng = Range("A1:A100")
for each cell in rng("A1:A100")
v = split(cell.Text,",")
for i = lbound(v) to ubound(v)
c1 = application.countif(rng,"*" & v(i) &"*")
if c1 1 then ' it should be 1 to match itself
msgbox v(i) & " possible dups"
cell.Interior.ColorIndex = 3
end if
next
Next
End Sub

--
regards,
Tom Ogilvy


"Janis" wrote:

I have random program numbers in a cell in each row for example in R4,C4,
406518,417615, 42586. I need to run through all the rows with a loop to
check that there are no duplicate numbers in any of the other cells. I need
an inner and an outer loop. I have the outer loop I think. I need to
compare the first line cell contents and then run through every row to make
sure the first program numbers aren't in any other cells. Then I need to
proceed to the second line compare those numbers with every other line
through the end of the spread sheet ensuring that there are no duplicate
program numbers in the 2nd column.

Here is all I have so far:
Sub ckDups()
Range("R1C2").Select
Do While ActiveCell.Value < ""
???????????
ActiveCell.Offset(1, 0).Select
Loop
End Sub

thanks very much



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 360
Default loop to check for duplicates Newbie pls help

Oh, I figured out you need the quotes. Thanks again.

"Tom Ogilvy" wrote:

Without knowing anything more about your numbers, I would go with this.
Change A1:A100 to reflect the cells you want to check

Sub ABC()
Dim rng as Range, cell as Range
Dim i as Long, c1 as Long
set rng = Range("A1:A100")
for each cell in rng("A1:A100")
v = split(cell.Text,",")
for i = lbound(v) to ubound(v)
c1 = application.countif(rng,"*" & v(i) &"*")
if c1 1 then ' it should be 1 to match itself
msgbox v(i) & " possible dups"
cell.Interior.ColorIndex = 3
end if
next
Next
End Sub

--
regards,
Tom Ogilvy


"Janis" wrote:

I have random program numbers in a cell in each row for example in R4,C4,
406518,417615, 42586. I need to run through all the rows with a loop to
check that there are no duplicate numbers in any of the other cells. I need
an inner and an outer loop. I have the outer loop I think. I need to
compare the first line cell contents and then run through every row to make
sure the first program numbers aren't in any other cells. Then I need to
proceed to the second line compare those numbers with every other line
through the end of the spread sheet ensuring that there are no duplicate
program numbers in the 2nd column.

Here is all I have so far:
Sub ckDups()
Range("R1C2").Select
Do While ActiveCell.Value < ""
???????????
ActiveCell.Offset(1, 0).Select
Loop
End Sub

thanks very much

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
VBA Newbie: Help with Do Loop code Carl Excel Discussion (Misc queries) 3 December 2nd 04 07:04 PM
VBA Newbie: Help with Do Loop code Carl[_5_] Excel Programming 3 December 2nd 04 07:04 PM
Loop macro for a Newbie mike Excel Programming 3 December 31st 03 06:35 PM
newbie: stop a FOR NEXT loop Mike H[_7_] Excel Programming 4 October 11th 03 04:47 PM
Newbie. Please help me find a loop solution Nigel Brown[_2_] Excel Programming 0 July 16th 03 10:25 AM


All times are GMT +1. The time now is 03:21 PM.

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

About Us

"It's about Microsoft Excel"