Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Excel VBA > Excel VBA
Excel VBA Discuss using VBA for Excel programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Excel VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old May 29th, 2007, 03:25 AM
Authorized User
Join Date: Mar 2007
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Default Detecting duplicate values

I have a list of ships and their details that I copy from the Lloyds register.
One of the details is the IMO nr. that is unique. Is there a way that I can check if this value is already in the list and warn me of this.


Old May 29th, 2007, 03:47 AM
Friend of Wrox
Join Date: Sep 2005
Posts: 812
Thanks: 1
Thanked 53 Times in 49 Posts

Here is a simple way

Sub CheckForIMR()

If Check_Existence_Of_IMO() = True Then
    MsgBox "IMO nr exists"
End If
End Sub

Function Check_Existence_Of_IMO(ByVal sText) As Boolean

Dim rFnd As Range
Dim sText As String

Set rFnd = ActiveSheet.Range("A:A").Find(What:=sText, LookAt:=xlPart)
If Not rFnd Is Nothing Then
    Check_Existence_Of_IMR = True
    Check_Existence_Of_IMR = False

End If

End Function

Just replace the range where it needs to be checked Range("A:A")


Old May 29th, 2007, 07:09 AM
Authorized User
Join Date: Mar 2007
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts

Thanx Shasur for the super quick help


Similar Threads
Thread Thread Starter Forum Replies Last Post
I need to omit the duplicate values when displayin ppakala XSLT 1 June 24th, 2008 06:13 PM
How Do I avoid duplicate values xsltier XSLT 3 June 4th, 2008 01:36 PM
how can i check for duplicate values before saving noor ASP.NET 1.0 and 1.1 Basics 3 June 10th, 2005 09:28 AM
Avoid duplicate node values nambati XSLT 1 September 8th, 2004 02:41 PM
Detecting duplicate rows. Daniel Walker PHP Databases 6 June 21st, 2004 02:39 AM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.