It has been a long while since i've coded in VB. I am tring to create standard data entry form for and excel file. Now i have the code to create the list but i do not want Multiple records with the same data. So i would like to create a validation check with in my empty cell loop.
the logic path i'm thinking is
If A1 matches txtNmL (last name) Check If B1 matches txtNmF (first name). IF both are true then message box recored Exsit for this person. Then skip out of the loop and allow editing to that record if needed. Else Contiue search for empty cell to add new record.
This is what i have so far
Private Sub CmdAdd_Click()
ActiveWorkbook.Sheets("WalkersB").Activate
Range("A1").Select
Do
If IsEmpty(ActiveCell) = False Then <--------I'd like to do the validation here-----------------
ActiveCell.Offset(1, 0).Select
End If
Loop Until IsEmpty(ActiveCell) = True
ActiveCell.Value = txtNmL.Value
ActiveCell.Offset(0, 1) = txtNmF.Value
ActiveCell.Offset(0, 2) = CboPos.Value
ActiveCell.Offset(0, 3) = txtStime.Value
ActiveCell.Offset(0, 4) = txtLtime.Value
ActiveCell.Offset(0, 5) = txtEtime.Value
Range("A1").Select
Call UserForm_Initialize
End Sub
Any help would be much appreciated.
Thanks
This post has been edited by macosxnerd101: 05 November 2010 - 02:46 PM
Reason for edit:: Added code tags.

New Topic/Question
Reply




MultiQuote



|