![]() |
Check for previous entry
I am making a user form that inputs information on a worksheet, it will
be making multiple entries for each row based on radio buttons on the form, the question i have is, is it possible to check a range of cells for a previous entry of the same value that the form is trying to put in the cell? Basically, i'm making a time sheet input that will enter the employee name in the A column then an in or out time (selected by radio buttons) in either B for in or C for out. I want to first search the previous entries of A for the employee to make sure i don't get two lines of the same employee. The employee name is being set by a combo box on the form. Any Suggestions? |
Check for previous entry
Craig, Try something like this:
Private Sub CmdEnter_Click() Dim CurRng As Range For Each CurRng In Range("EmployeeNames") If CurRng = CboNames Then MsgBox "We Have an attempt at a duplicate entry in cell " _ & CurRng.Address Exit For End If Next CurRng End Sub You can replace the MsgBox function with the code that you want to take it's place. By the way CboNames is the ComboBox name and Range("EmployeeNames") represents the area of the sheet where your names reside (Column A I guess) just in case you didn't get that. Hope that gets ya rollin... Mark |
Check for previous entry
Craig,
Something like this? NameButton is a button on the form. The TestForName sub can go in a standard module or in the Form module. Jim Cone San Francisco, USA '----------------------------- Private Sub NameButton_Click() TestForName End Sub Sub TestForName() Dim strValue As String strValue = UserForm1.ComboBox1.Value If IsError(Application.Match(strValue, Range("A1:A100"), 0)) Then MsgBox "Ok to use " Else MsgBox "Not ok to use " End If End Sub '------------------------- "Craig" wrote in message oups.com I am making a user form that inputs information on a worksheet, it will be making multiple entries for each row based on radio buttons on the form, the question i have is, is it possible to check a range of cells for a previous entry of the same value that the form is trying to put in the cell? Basically, i'm making a time sheet input that will enter the employee name in the A column then an in or out time (selected by radio buttons) in either B for in or C for out. I want to first search the previous entries of A for the employee to make sure i don't get two lines of the same employee. The employee name is being set by a combo box on the form. Any Suggestions? |
All times are GMT +1. The time now is 05:39 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com