Hello,
On the Paint Detail sheet there is code to save record. Can the code be modified so it updates the existing record instead of adding a new record? There shouldn't be duplicate paint code names.
Thank you for your help
Hello,
On the Paint Detail sheet there is code to save record. Can the code be modified so it updates the existing record instead of adding a new record? There shouldn't be duplicate paint code names.
Thank you for your help
Try this code :...
PHP Code:
Sub Paint_Save()
ActiveSheet.Unprotect
With Sheet2
If .Range("E5").Value = Empty Then
MsgBox "Please enter a paint code"
Exit Sub
End If
PaintRow = Evaluate("=Iferror(Match(E5, D:D, 0),99999)") ' new code: PaintRow = 99999, old code: PaintRow = row_Index
If PaintRow <> 99999 Then ' if old code
If MsgBox("Its about to edit information! Continue?", vbYesNo) = vbNo Then Exit Sub
Else ' new code
PaintRow = .Range("D99999").End(xlUp).Row + 1 'First available Row
End If
For PaintCol = 4 To 7
.Cells(PaintRow, PaintCol).Value = .Range(.Cells(11, PaintCol).Value).Value
Next PaintCol
.Range("B3").Value = False
End With
ActiveSheet.Protect
End Sub
Quang PT
Thank you very much @bebo021999. Your code works great!
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks