Hello, ever have one of those codes that just keep making you hit your head on the keyboard? lol As soon as I get one quirk figured out another one pops up. I am using the code below to pass information from a userform to two different WS's. Initially I was having issues with a listbox values but I got that sorted out. Now I have an issue with the data being sent to the worksheets. In the code, separately each both work perfect but when I put them together the entries on worksheet "Repair Log" gets repeated (as in entered) 26 times! It doesn't do it when I disable the code for the "Device List" section so it appears to be coming from that section. I am at a loss as to why it is happening 26 times, why 26?
Does anyone have any thoughts on why it is doing this and how I can stop it? I appreciate all of the assistance - thanks,
Does anyone have any thoughts on why it is doing this and how I can stop it? I appreciate all of the assistance - thanks,
VBA Code:
Private Sub CommentButton_Click()
Dim i As Long
Dim Lastrow As Long
Dim Found As Range
Worksheets("Device List").Activate
Lastrow = Cells(Rows.Count, "A").End(xlUp).Row
For i = 1 To Lastrow
If Cells(i, 8).Value = "FAIL" And Cells(i, 7).Value = "" Then
Cells(i, 7).Value = RepairComments.Value
Exit For
End If
'''''''''''''''''''''''
With Sheets("Repair Log")
nextrow = .Range("A" & Rows.Count).End(xlUp).Row + 1
.Range("A" & nextrow) = DeviceId.Value
.Range("B" & nextrow) = Now()
.Range("C" & nextrow) = RepairComments.Value
End With
''''''''''''''''''''''''
Next
Unload DataEntry
DataEntry.Show
Unload RepairForm
RepairForm.Show
If Sheets("Coding").Range("H8").Value > 0 Then
RepairForm.Show
Else
Unload RepairForm
MsgBox "No further repair comments are needed", , "Repair Comments"
End If
End Sub