EDUCATED MONKEY
Board Regular
- Joined
- Jul 17, 2011
- Messages
- 218
hello i would like some help with the code below, it works reasonably well but requires me to click the cell that data has just been pasted into, what i would like is that it runs when data is pasted in
VBA Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim intersection As Range
Dim box As Integer 'the row in column K
Dim postalServiceId As String
Set intersection = Intersect(Target, Range("K:K"))
If Not intersection Is Nothing Then
box = Target.Row
postalServiceId = Worksheets("extractedData").Cells(box, 11).Value 'get the number
If (Len(postalServiceId) > 14) Then ' greater the 14 must be hermes
Worksheets("extractedData").Cells(box, 10).Value = "hermes"
Cells(box, 3).Interior.Color = RGB(0, 255, 0) 'change the order number to green
ElseIf (Len(postalServiceId) = 14) Then ' must be royal mail
Worksheets("extractedData").Cells(box, 10).Value = "royal mail"
Cells(box, 3).Interior.Color = RGB(0, 255, 0) 'change the order number to green
End If
End If
End Sub