Advertisement
Guest User

Untitled

a guest
Jun 26th, 2019
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.25 KB | None | 0 0
  1. Private Sub Worksheet_Change(ByVal Target As Range)
  2.  
  3. If Not Application.Intersect(Range("D2:L4"), Range(Target.Address)) Is Nothing Then
  4. 'If you add (an)other row(s) edit this code above
  5. Call DeleteP2P4
  6. 'If you add (an)other row(s) edit this code above
  7. Call SampleMacro
  8. End If
  9.  
  10. End Sub
  11.  
  12. Sub DeleteP2P4()
  13. Range("P2:P4").Select
  14. 'If you add (an)other row(s) edit this code above
  15. Selection.ClearContents
  16. End Sub
  17.  
  18. Sub SampleMacro()
  19.  
  20. ' Get the last row
  21. Dim startRow As Long, lastRow As Long
  22. startRow = 2
  23. lastRow = Sheet1.Cells(Sheet1.Rows.Count, 1).End(xlUp).Row
  24.  
  25. For i = startRow To lastRow
  26.  
  27. ' If there's Yes/Mediocre in D column, then append next number
  28. If Sheet1.Range("D" & i).Value = "Yes" Then
  29. Sheet1.Range("P" & i).Value = "+1"
  30. ElseIf Sheet1.Range("D" & i).Value = "Mediocre" Then
  31. Sheet1.Range("P" & i).Value = "+0.5"
  32. End If
  33.  
  34. ' If there's Yes/Mediocre in E column, then append next number
  35. If Sheet1.Range("E" & i).Value = "Yes" Then
  36. Sheet1.Range("P" & i).Value = "+1"
  37. ElseIf Sheet1.Range("E" & i).Value = "Mediocre" Then
  38. Sheet1.Range("P" & i).Value = "+0.5"
  39. End If
  40.  
  41. 'It continious here with the rest of the If statements
  42.  
  43. Next
  44.  
  45. End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement