Hello,
I am new to working with VBA, and therefore I'm learning on the go. I have a worksheet, in which I need to decide whether an issue should go after logistics, finances or quality, based on a criteria written in another cell. I found this code and edited it to work better for my purposes, but I have stumbled upon a problem. Whenever I type in "Late delivery", at first the macro does what it should and writes the word "Logistics" where I need it to. But, after few seconds window pops up, and it says:
Run-time error '1004': Method 'Range' of object '_Worksheet' failed
Then, if I click on debug or anything else, excel crashes. Could you by any chance help me please?
This is the code in question
Thank you very much
I am new to working with VBA, and therefore I'm learning on the go. I have a worksheet, in which I need to decide whether an issue should go after logistics, finances or quality, based on a criteria written in another cell. I found this code and edited it to work better for my purposes, but I have stumbled upon a problem. Whenever I type in "Late delivery", at first the macro does what it should and writes the word "Logistics" where I need it to. But, after few seconds window pops up, and it says:
Run-time error '1004': Method 'Range' of object '_Worksheet' failed
Then, if I click on debug or anything else, excel crashes. Could you by any chance help me please?
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim LastRow As Long
Dim i As Long
LastRow = Range("A" & Rows.Count).End(xlUp).Row
For i = 2 To LastRow
If Range("A" & i).Value = "Late delivery" Then
Range("B" & i).Value = "Logistics"
End If
Next i
End Sub
This is the code in question
Thank you very much