I am trying to set up a loop to check a column of numbers in Excel, to ensure that a number being added to this column does not already exsist.
I am having trouble getting the loop to break off when it evaluates, there is no chance for more than one duplication of a number in this column. and the number of rows can vari.
A user will add a number through a form. If the number is already in a column on another sheet then I want to prompt the user to select another number, otherwise have the rest of the macros continue.
Here is what I have
Dim test As Integer
Dim checked As Integer
x = Worksheets("Form".Range("new"
c = ActiveCell
For Each c In Worksheets("IMPORT".Range("veh1"
If x Like c Then
test = MsgBox(".....! Please Select a Different Number ", vbCritical + vbOKCancel, "Vehicle Number"
Select Case test
Case vbOK: Range("new".Select
Case vbCancel: End Select
ElseIf Not x Like c Then
checked = MsgBox("...?", vbCritical + vbYesNo, "Vehicle Information"
Select Case checked
Case vbYes: movedata
Case vbNo: End Select
End If
Next
End Sub
Thanks Curt
I am having trouble getting the loop to break off when it evaluates, there is no chance for more than one duplication of a number in this column. and the number of rows can vari.
A user will add a number through a form. If the number is already in a column on another sheet then I want to prompt the user to select another number, otherwise have the rest of the macros continue.
Here is what I have
Dim test As Integer
Dim checked As Integer
x = Worksheets("Form".Range("new"
c = ActiveCell
For Each c In Worksheets("IMPORT".Range("veh1"
If x Like c Then
test = MsgBox(".....! Please Select a Different Number ", vbCritical + vbOKCancel, "Vehicle Number"
Select Case test
Case vbOK: Range("new".Select
Case vbCancel: End Select
ElseIf Not x Like c Then
checked = MsgBox("...?", vbCritical + vbYesNo, "Vehicle Information"
Select Case checked
Case vbYes: movedata
Case vbNo: End Select
End If
Next
End Sub
Thanks Curt