Chewyhairball
Active Member
- Joined
- Nov 30, 2017
- Messages
- 312
- Office Version
- 365
- Platform
- Windows
Hi
When i input a value in column C it populates various other cells in the same row and when I delete an item in column C it returns cells in the same row to blank.
This works fine for me but I am trying to add some code that says if column J contains the word 'Approved' then when you try to delete and item in column 'C in the same row as this
you get a message saying you cant delete it and the code exits.
any help with this would be great.
thanks
When i input a value in column C it populates various other cells in the same row and when I delete an item in column C it returns cells in the same row to blank.
This works fine for me but I am trying to add some code that says if column J contains the word 'Approved' then when you try to delete and item in column 'C in the same row as this
you get a message saying you cant delete it and the code exits.
any help with this would be great.
thanks
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim cell As Range
For Each cell In Target
On Error Resume Next
If cell.Column = Range("C10:C2000").Column Then
If cell.Value <> "" Then
Cells(cell.Row, "D").Value = Application.WorksheetFunction.VLookup(Cells(cell.Row, "C"), Sheets("Item plus supplier").Range("C2:D2000"), 2, False)
Else
Cells(cell.Row, "D").Value = ""
End If
End If
If cell.Column = Range("C10:C2000").Column Then
If cell.Value <> "" Then
Cells(cell.Row, "G").Value = Now & " " & Environ("UserName")
Cells(cell.Row, "H").Value = "New Request"
Cells(cell.Row, "J").Value = ""
Cells(cell.Row, "p").Value = Environ("UserName")
Cells(cell.Row, "Q").Value = ""
Cells(cell.Row, "i").Select
Call ShowShapes
ActiveCell.Offset(1, -6).Activate
Else
Cells(cell.Row, "D").Value = ""
Cells(cell.Row, "E").Value = ""
Cells(cell.Row, "F").Value = ""
Cells(cell.Row, "G").Value = ""
Cells(cell.Row, "H").Value = ""
Cells(cell.Row, "K").Value = ""
Cells(cell.Row, "L").Value = ""
Cells(cell.Row, "M").Value = ""
Cells(cell.Row, "P").Value = ""
Cells(cell.Row, "Q").Value = ""
Cells(cell.Row, "H").ClearComments
Cells(cell.Row, "J").Value = ""
Cells(cell.Row, "i").Select
Call HideShapes
ActiveCell.Offset(0, -6).Activate
End If
End If
If cell.Column = Range("J:J").Column Then
If cell.Value = "Purchase Order Raised" Then
Cells(cell.Row, "N").Value = "by " & Environ("UserName") & " " & Now
End If
End If
If cell.Column = Range("J:J").Column Then
If cell.Value = "Ordered" Then
Cells(cell.Row, "O").Value = "by " & Environ("UserName") & " " & Now
End If
End If
Next cell
End Sub