Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Microsoft Office > Excel VBA > Excel VBA
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old May 29th, 2007, 03:25 AM
Authorized User
 
Join Date: Mar 2007
Location: , , Netherlands.
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.

Thanx
John

Reply With Quote
  #2 (permalink)  
Old May 29th, 2007, 03:47 AM
Friend of Wrox
Points: 3,060, Level: 23
Points: 3,060, Level: 23 Points: 3,060, Level: 23 Points: 3,060, Level: 23
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Sep 2005
Location: , , .
Posts: 812
Thanks: 1
Thanked 53 Times in 49 Posts
Default

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
Else
    Check_Existence_Of_IMR = False

End If

End Function

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

Cheers
Shasur


http://www.vbadud.blogspot.com
Reply With Quote
  #3 (permalink)  
Old May 29th, 2007, 07:09 AM
Authorized User
 
Join Date: Mar 2007
Location: , , Netherlands.
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanx Shasur for the super quick help

John

Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

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



All times are GMT -4. The time now is 08:00 AM.


Powered by vBulletin®
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.