VBA Code:
Sub Defect_2()
'
' Defect Macro
'
'
Dim cell As Range, RngB
Dim mycol As Long, CngB As Range
If Range("B2") = "" Then
Exit Sub
End If
mycol = Sheets("Count sheet").Rows(1).Find("Defect", , xlValues, , xlByColumns, xlPrevious).Column
Set CngB = Columns(mycol)
RngB = Sheets("Inventory management").Range("B2").Value
For Each cell In Sheets("Count sheet").Range("A2:A8000")
If cell.Value = RngB Then Sheets("Count sheet").Cells(cell.Row, mycol).Offset(, 2) = Sheets("Inventory management").Range("E2")
Next
Sheets("Count sheet").Columns(mycol + 2).Insert Shift:=xlToRight, Copyorigin:=xlFormatFromLeftOrAbove
Sheets("Inventory management").Range("E2").ClearContents
Sheets("Inventory management").Range("B2").ClearContents
End Sub
What I'm trying to do is when it pastes to mycol it puts a date stamp in row one of that column like if i hit submit and it posts 2 in J(whatever) then in J1 it dates it