Hi guys, i am creating an excel spreadsheet that contains 3 identical spreadsheets for different car bays that allows a user to type in a date which is then searched for in the spreadsheet. once it has been found a car registration is entered in underneath the date. if there is already a car in the bay, it moves to the next sheet and tries the same again. once this has been done it finds a mechanic that isnt already working on a car and puts the mechanic in with the car.
now i have started the coding at the moment to find the date which works, but when i try to enter the car registration underneath the date it doesnt work.
here is the code i currently have:
[VBA]
sub xx()
Dim datatoFind
Dim sheetCount As Integer
Dim counter As Integer
Dim currentSheet As Integer
On Error Resume Next
currentSheet = ActiveSheet.Index
datatoFind = TextBox1.Text
'If datatoFind = "" Then Exit Sub
sheetCount = ActiveWorkbook.Sheets.Count
If IsError(CDbl(datatoFind)) = False Then datatoFind = CDbl(datatoFind)
For counter = 1 To sheetCount
Sheets(counter).Activate
Cells.Find(What:=datatoFind, After:=ActiveCell, LookIn:=xlFormulas, LookAt _
:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:= _
False).Activate
If ActiveCell.Value = datatoFind Then 'Exit Sub
ActiveWorkbook.Sheets().Select
Range("A1").Select
row = Range(Selection, Selection.End(xlDown)).Count
nextrow = row + 1
If row <> "" Then nextrow = row + 1
Else
Range(nextrow).Value = Me.TextBox1.Text
End If
Exit Sub
Next counter
If ActiveCell.Value <> datatoFind Then
MsgBox ("Value not found")
Sheets(currentSheet).Activate
End If
End Sub
[/VBA]