ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Check a cell for duplicates. (https://www.excelbanter.com/excel-programming/299302-check-cell-duplicates.html)

Unknown_User[_5_]

Check a cell for duplicates.
 
With your help I have now managed to produce a really useful spreadshee
but I am being driven nuts by my inability to finish the final part!

Along with a bunch of other stuff my code creates a random number.

I have managed to find the next available cell in column A on a give
spreadsheet and place the number there.

What I want to do before entering the number is check that it doesn'
already exist somewhere in that column. If it is already present I wan
to loop until a unique one is found.

I have no doubt that this is really easy but I am just too dumb.....!

Thanks for your help

--
Message posted from http://www.ExcelForum.com


Frank Kabel

Check a cell for duplicates.
 
Hi
see: http://www.cpearson.com/excel/NoDupEntry.htm

--
Regards
Frank Kabel
Frankfurt, Germany


With your help I have now managed to produce a really useful
spreadsheet but I am being driven nuts by my inability to finish the
final part!

Along with a bunch of other stuff my code creates a random number.

I have managed to find the next available cell in column A on a given
spreadsheet and place the number there.

What I want to do before entering the number is check that it doesn't
already exist somewhere in that column. If it is already present I
want to loop until a unique one is found.

I have no doubt that this is really easy but I am just too dumb.....!

Thanks for your help.


---
Message posted from http://www.ExcelForum.com/



Unknown_User[_6_]

Check a cell for duplicates.
 
....sorry to be such a newbie here.

I have read the link, how do I use COUNTIF within my VB?

This seems to be a function within excel, I'm not sure how to access i
within the code.

Thanks

--
Message posted from http://www.ExcelForum.com


Unknown_User[_7_]

Check a cell for duplicates.
 
...worked it out guys.

Private Sub CommandButton1_Click()

With Worksheets("Sheet1").Columns("A:A")
Do
rand = Rnd()
Set oCell = .Find(rand)
Loop Until oCell Is Nothing
Worksheets("Sheet1").Range("a1").Value = rand
End With

End Su

--
Message posted from http://www.ExcelForum.com



All times are GMT +1. The time now is 01:17 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com