Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 709
Default Unique entries in textbox

Hello,

I have a form that enters data into columns A - O. Column F must be unique.
The sheet is called DataEntry and the textbox is called tSerial. I have
read previous posts regarding similiar scenarios however, I cannot seem to
get it to work. I need the Form to reject a duplicate entry in Column F
(other than blanks), so that a Msgbox appears, but the current data is not
removed or added once the Add Entry button is pressed.

Thanks in advance. . .
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 923
Default Unique entries in textbox

This might give you a start?

Private Sub tfield_Exit(ByVal Cancel As MSForms.ReturnBoolean)
If Len(Trim(tfield.Value)) 0 Or tfield.Value = vbNull Then
Dim xr As Long
For xr = 1 To Worksheets("DataEntry").Cells(Rows.Count,
"F").End(xlUp).Row
If CStr(Worksheets("DataEntry").Cells(xr, 6).Value) =
CStr(Trim(tfield.Value)) Then
MsgBox "Key field is Duplicate!"
Exit Sub
End If
Next xr
Else
MsgBox "Key field is Empty!"
End If
End Sub


--
Cheers
Nigel



"Richard" wrote in message
...
Hello,

I have a form that enters data into columns A - O. Column F must be

unique.
The sheet is called DataEntry and the textbox is called tSerial. I have
read previous posts regarding similiar scenarios however, I cannot seem to
get it to work. I need the Form to reject a duplicate entry in Column F
(other than blanks), so that a Msgbox appears, but the current data is not
removed or added once the Add Entry button is pressed.

Thanks in advance. . .



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 709
Default Unique entries in textbox

Yes, this was a perfect start. I then used the Len below as a check to
reject blank entries from being made.

Thanks

"Nigel" wrote:

This might give you a start?

Private Sub tfield_Exit(ByVal Cancel As MSForms.ReturnBoolean)
If Len(Trim(tfield.Value)) 0 Or tfield.Value = vbNull Then
Dim xr As Long
For xr = 1 To Worksheets("DataEntry").Cells(Rows.Count,
"F").End(xlUp).Row
If CStr(Worksheets("DataEntry").Cells(xr, 6).Value) =
CStr(Trim(tfield.Value)) Then
MsgBox "Key field is Duplicate!"
Exit Sub
End If
Next xr
Else
MsgBox "Key field is Empty!"
End If
End Sub


--
Cheers
Nigel



"Richard" wrote in message
...
Hello,

I have a form that enters data into columns A - O. Column F must be

unique.
The sheet is called DataEntry and the textbox is called tSerial. I have
read previous posts regarding similiar scenarios however, I cannot seem to
get it to work. I need the Form to reject a duplicate entry in Column F
(other than blanks), so that a Msgbox appears, but the current data is not
removed or added once the Add Entry button is pressed.

Thanks in advance. . .




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
Unique entries jc132568 New Users to Excel 4 September 4th 09 05:02 AM
sum unique entries only Jo Excel Discussion (Misc queries) 0 April 30th 09 05:26 AM
Unique Entries Alan Excel Discussion (Misc queries) 3 August 1st 08 05:42 PM
Unique Entries SJT Excel Discussion (Misc queries) 10 November 11th 06 02:02 PM
unique entries scrabtree[_2_] Excel Programming 7 August 1st 04 06:36 PM


All times are GMT +1. The time now is 08:51 PM.

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"