Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 30
Default validating data in acolumn

Hi all, I've got a column of invoice numbers and each time I add one I want
to make sure it it is not duplicated. I've tried using a function with
copy/paste validation, but it doesn't always work as the invoices can be text
as well as number. Any ideas. Thanks very much.
--
delmac
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default validating data in acolumn


How about something like this? Of course you can make the inputbox a
specific cell or the activecell if you choose... that's just an example
since you didn't specify. Hope that helps.

Sub MyTest()
Dim MyStr As String
MyStr = InputBox("New Invoice:")
Columns("A:A").Select
Range("A1").Activate
On Error GoTo NoDuplicate
Selection.Find(What:=MyStr, LookAt:=xlWhole).Activate
GoTo Duplicate
Duplicate:
'Code for if duplicate is found
Exit Sub
NoDuplicate:
'Code for if NO duplicate is found
Exit Sub
End Sub


delmac Wrote:
Hi all, I've got a column of invoice numbers and each time I add one I
want
to make sure it it is not duplicated. I've tried using a function with
copy/paste validation, but it doesn't always work as the invoices can
be text
as well as number. Any ideas. Thanks very much.
--
delmac



--
Ikaabod
------------------------------------------------------------------------
Ikaabod's Profile: http://www.excelforum.com/member.php...o&userid=33371
View this thread: http://www.excelforum.com/showthread...hreadid=542146

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 74
Default validating data in acolumn

Hi,

You could attach some code to the code module for the worksheet & trap the
worksheet change event.

Provided you have a named range called "invoicenumbers" the following may
help;

Private Sub Worksheet_Change(ByVal Target As Range)

Dim ranCell As Excel.Range
Dim iPointer As Integer

For Each ranCell In Application.Intersect(Target,
Me.Range("invoicenumbers"))

If ranCell < "" Then

For iPointer = 0 To (ranCell.Row -
Me.Range("invoicenumbers").Cells(1, 1).Row - 1)

If Me.Range("invoicenumbers").Cells(iPointer + 1, 1) =
ranCell Then

MsgBox "Duplicates with row " & (iPointer +
Me.Range("invoicenumbers").Cells(1, 1).Row)
ranCell = ""
Exit Sub

End If

Next

End If

Next ranCell

End Sub

Regards,

Chris.

--
Chris Marlow
MCSD.NET, Microsoft Office XP Master


"delmac" wrote:

Hi all, I've got a column of invoice numbers and each time I add one I want
to make sure it it is not duplicated. I've tried using a function with
copy/paste validation, but it doesn't always work as the invoices can be text
as well as number. Any ideas. Thanks very much.
--
delmac

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
Connecting of two data validating with each other Akhil Excel Worksheet Functions 1 August 10th 06 09:01 PM
validating data in a combobox Jono Excel Worksheet Functions 0 March 13th 06 05:51 PM
avoid retype the number more than one time withen acolumn This no. already exist Excel Discussion (Misc queries) 1 April 4th 05 10:25 AM
Validating data in a spreadsheet control Nuncle[_2_] Excel Programming 0 September 30th 04 08:00 AM
Validating entered data as date Mr. B[_3_] Excel Programming 2 April 9th 04 01:40 PM


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