Macro issue by inserting or deleting a row!

Jurajko

New Member
Joined
Feb 24, 2019
Messages
5
Hi everyone,
i need a help with the VBA code, that should insert the current date and username as soon as the word "done" is inserted in some of the cells in the column S.
It works until I delete or insert a new row. Then I get the Issue ´13´ and the line with If Target.Value ="done" is highlighted.
Can you help me to adjust the code, so it works without any Issue? Thank you in advance!

Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target, Range("S:S")) Is Nothing Then
If Target.Value = "Done" Then
Target.Offset(0, 7).Value = Date
Target.Offset(0, 8).Value = Environ("username")
Else
Target.Offset(0, 7).ClearContents
Target.Offset(0, 8).ClearContents
End If
End If
End Sub
 
Jurajko,

Cross-posting (posting the same question in more than one forum) is not against our rules, but you must use the method of doing so covered by #13 of the Forum Rules.
If you do cross-post in the future, please follow these rules and provide the links amd then there shouldn’t be a problem.
ok, sorry, i posted it on only these 2 Forums
 
Upvote 0

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".
no, i used your code ;)
The marked solution has been changed accordingly. In your future questions, please mark the post as the solution that actually answered your question, instead of your feedback message as it will help future readers. No further action is required for this thread.
 
Upvote 0

Forum statistics

Threads
1,214,414
Messages
6,119,375
Members
448,888
Latest member
Arle8907

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top